Created
February 20, 2016 21:45
-
-
Save rossharper/6b5a9a414edb00cd12a6 to your computer and use it in GitHub Desktop.
Java example of a parameterized test for the Roman Numerals Kata
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(Parameterized.class) | |
public class JavaTest { | |
private final int paramOne; | |
private final String paramTwo; | |
@Parameterized.Parameters | |
public static List<Object[]> data() { | |
return Arrays.asList(new Object[][] { | |
{1, "I"}, // First test: (paramOne = 1, paramTwo = "I") | |
{1999, "MCMXCIX"} // Second test: (paramOne = 1999, paramTwo = "MCMXCIX") | |
}); | |
} | |
public JavaTest(int paramOne, String paramTwo) { | |
this.paramOne = paramOne; | |
this.paramTwo = paramTwo; | |
} | |
@Test | |
public void shouldReturnExpectedRomanForArabic() { | |
assertThat(new RomanNumeralGenerator().arabicToRoman(paramOne), equalTo(paramTwo)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment