Skip to content

Instantly share code, notes, and snippets.

@sachi-d
Created November 3, 2020 09:38
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 sachi-d/88c9dfbcbc0d5ad75d5eb8359893d8ad to your computer and use it in GitHub Desktop.
Save sachi-d/88c9dfbcbc0d5ad75d5eb8359893d8ad to your computer and use it in GitHub Desktop.
@RunWith(Parameterized.class)
public class AdderTest extends TestCase {
@Parameterized.Parameters(name = "{index}: add[{0}, {1}]={2}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{0, 0, 0},
{1, 1, 2},
{2, 1, 3},
{100, 400, 500},
{99, 1, 100}
});
}
int input1;
int input2;
int expectedOutput;
public AdderTest(int i1, int i2, int expected) {
input1 = i1;
input2 = i2;
expectedOutput = expected;
}
@Test
public void testAdd() {
assertEquals(expectedOutput, Computer.add(input1, input2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment