JUnits reporting failures locally, errors on build
I am running a small suite of JUnit tests in an automated build system. The JUnits are currently very simple one-line tests such as assertEquals(true, false). Just to check the JUnit logging functionality.
When I run these tests locally, I get reports of failing test cases, as I expect. When these same tests are run on the build server (using ant <junit> ) instead of failures I get errors. The error message I get is:
The test case in question:
The version of JUnit being used in the ant scripts is 4.3.1
Has anyone come across this kind of thing before? I can't think of what may be causing it.
Cheers,
Jon
When I run these tests locally, I get reports of failing test cases, as I expect. When these same tests are run on the build server (using ant <junit> ) instead of failures I get errors. The error message I get is:
java.lang.AssertionError: expected:<false> but was:<true>
at com.ibm.dfdl.api.parser.tests.ParserTests.testToFail(ParserTests.java:30)
The test case in question:
@Test
public void testToFail(){
Assert.assertEquals(false, true);
}
The version of JUnit being used in the ant scripts is 4.3.1
Has anyone come across this kind of thing before? I can't think of what may be causing it.
Cheers,
Jon
One answer
I have fixed the problem to a degree. Using a JUnit4TestAdapter caused the failures to be seen as errors. Looking at the JUnit ant page gave me a clue that this was the problem:
The failures are now reported as errors as desired.
This task has been tested with JUnit 3.0 up to JUnit 3.8.2; it won't work with versions prior to JUnit 3.0. It also works with JUnit 4.0, including "pure" JUnit 4 tests using only annotations and no JUnit4TestAdapter.
The failures are now reported as errors as desired.