It's all about the answers!

Ask a question

JUnits reporting failures locally, errors on build


Jon Norman (1633) | asked Mar 06 '12, 9:42 a.m.
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:

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



permanent link
Jon Norman (1633) | answered Mar 07 '12, 9:39 a.m.
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:

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.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.