Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:

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

0 votes



One answer

Permanent link
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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Mar 06 '12, 9:42 a.m.

Question was seen: 3,841 times

Last updated: Mar 06 '12, 9:42 a.m.

Confirmation Cancel Confirm