Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrules6872/83ce6e7d8ec612aef814f4e2c4ac2420 to your computer and use it in GitHub Desktop.
Save hrules6872/83ce6e7d8ec612aef814f4e2c4ac2420 to your computer and use it in GitHub Desktop.
Parameterized JUnit4 test example in Kotlin
@RunWith(Parameterized::class)
class KotlinTest(val paramOne: Int, val paramTwo: String) {
companion object {
@JvmStatic
@Parameterized.Parameters
fun data() : Collection<Array<Any>> {
return listOf(
arrayOf(1, "I"), // First test: (paramOne = 1, paramTwo = "I")
arrayOf(1999, "MCMXCIX") // Second test: (paramOne = 1999, paramTwo = "MCMXCIX")
)
}
}
@Test
fun shouldReturnExpectedRomanForArabic() {
assertThat(RomanNumeralGenerator().arabicToRoman(paramOne), equalTo(paramTwo));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment