I have written a TestCase
using a Runner
class to print the results. But when I try to print the results, I am getting only the first result and not all failures/results of the TestCase
.
My TestCase class is as below:
public class Fixtures_JavaTest extends TestCase{
protected int value1, value2;
public Fixtures_JavaTest(String str) {
super(str);
}
@Override
protected void setUp() throws Exception {
value1 = 2;
value2 = 5;
}
public void testAdd() {
assertEquals(7, 8);
assertEquals(4, 8);
assertEquals(3, 8);
assertEquals(2, 2);
}
}
My runner class is as below:
public class Runner_Fixtures_JavaTest {
public static void main(String[] args) {
TestCase test = new Fixtures_JavaTest("add") {
public void runTest() {
testAdd();
}
};
TestResult result = test.run();
Enumeration<TestFailure> failures = (Enumeration<TestFailure>) result.failures();
while(failures.hasMoreElements()) {
System.out.println(failures.nextElement());
}
}
}
I am getting the below result only
add(Runner_Fixtures_JavaTest$1): expected:<7> but was:<8>
Why am I not getting the output for below assertEqual
methods?
assertEquals(4, 8);
assertEquals(3, 8);
assertEquals(2, 2);