I'm using JUnit. I want to invoke assertEquals() many times in a test method to test many diferent test cases but I don't want to have many test method. So I use setUp() and tearDown(). But when the first assertEquals() fail.The second assertEquals()doesn't work and setUp() method just have been invoked one time.
Here is my code
public class ComputeServiceTest extends TestCase {
private ComputeServices instance = new ComputeServices();
public ComputeServiceTest(String name)
{
super(name);
}
protected void setUp()
{
System.out.println("aaaaaaaaaaaaaaaaaaaaa");
instance = new ComputeServices();
}
protected void tearDown() {
}
//test add method
public void testAdd1()
{
//instance = new ComputeServices();
//First test case
int x1 = 7;
int y1 = 5;
int expResult1 = 13;
int result1 = instance.add(x1, y1);
assertEquals("First test case fail",expResult1, result1);
// Second test case
System.out.println("AAAAAAAAAAAAAAAAAAAAAaaaaaaaaaa");
int x2 = 9;
int y2 = 6;
int expResult2 = 16;
int result2 = instance.add(x2, y2);
assertEquals("Second test case fail",expResult2, result2);
}
}
Pls help me to fix thi bug.