Skip to content

Instantly share code, notes, and snippets.

@kstefan
Created April 3, 2017 20:00
Show Gist options
  • Save kstefan/2617dfff0dbb1bec72eba05f69fb8dc3 to your computer and use it in GitHub Desktop.
Save kstefan/2617dfff0dbb1bec72eba05f69fb8dc3 to your computer and use it in GitHub Desktop.
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class MaxNumberParametrizedTest {
private final int input1;
private final int input2;
private final int expectedResult;
public MaxNumberParametrizedTest(int input1, int input2, int expectedResult) {
this.input1 = input1;
this.input2 = input2;
this.expectedResult = expectedResult;
}
@Parameters(name = "{index}: Math.max({0}, {1}) = {2}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] {
{ 0, 0, 0}, {1, 0, 1}, {2, 5, 5}, {10, 10, 10}
});
}
@Test
public void maximumOfTwoNumbers() {
assertEquals(expectedResult, Math.max(input1, input2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment