Hi!
I'm new in JUnit and I start reading about JUnit4.
I was reading but the only information I found was a simple overview.
Do you know about some book or tutorial which help me a little more.
my stronger question is: Can i use more than one parametrization on one testcase??? something like this:
//my class
public class OpMath {
public static int suma(int a, int b) {
return a + b;
}
public static int mult(int a, int b) {
return a * b;
}
public static float div(int a, int b) {
return a / b;
}
}
// testcase
@RunWith (Parameterized.class)
public class OpMathTest {
private int a;
private int b;
private int r;
public OpMathTest(int aa, int bb , int rr) {
a = aa;
b = bb;
r = rr;
}
@Parameters
public static Collection dataSuma() {
return Arrays.asList(new Object[][]{{0,0,0},{1,0,1},{1,1,2}});
}
@Test
public void testSuma() {
int raux = OpMath.suma(a,b);
assertEquals(r, raux);
}
@Parameters
public static Collection dataSuma() {
return Arrays.asList(new Object[][]{{0,0,0},{1,0,0},{1,1,1}});
}
@Test
public void testSuma() {
int raux = OpMath.mult(a,b);
assertEquals(r, raux);
}
}
this example doesn't work.... does exist an option to solved this problem?? or do i have to write a test case for each collection I want to test???
Thanks
Maria Sol