Created
October 29, 2019 16:15
-
-
Save harmittaa/7a1d7334578a65c22f7aaaca1a423d22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(ParameterizedRobolectricTestRunner::class) | |
@Config(sdk = [27]) | |
// parameters declared in the params() are injected through the constructor to the test class | |
class ExampleUnitTest(private val param: Int) { | |
@Test | |
fun addition_isCorrect() { | |
// parameter use in a test | |
assertEquals(param * 2, param + param) | |
} | |
companion object { | |
@JvmStatic | |
// name argument is optional, it will show up on the test results | |
@ParameterizedRobolectricTestRunner.Parameters(name = "Input: {0}") | |
// parameters are provided as arrays, allowing more than one parameter | |
fun params() = listOf( | |
arrayOf(1), | |
arrayOf(2), | |
arrayOf(3), | |
arrayOf(4) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment