Caused tests to run using JUnit 3 instead of JUnit 4

19 views
Skip to first unread message

Kevin Wong

unread,
Mar 24, 2011, 11:36:39 AM3/24/11
to usr-ivybeans
After switching my project to IvyBeans, my tests seem to be running
under JUnit 3 instead of JUnit 4.

compile-test-single:
Testsuite: cairoweb.server.MainServiceImplTest
Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.031 sec

Testcase: warning(junit.framework.TestSuite$1): FAILED
No tests found in cairoweb.server.MainServiceImplTest
junit.framework.AssertionFailedError: No tests found in
cairoweb.server.MainServiceImplTest

When I add the following to the test, it runs:


public static junit.framework.Test suite()
{
return new JUnit4TestAdapter(BeanComparatorTest.class);
}

Any ideas as to why this is happening? I have junit-4.7 in my Ivy
dependencies. I even added junit-4.7.jar back into my regular
NetBeans test libraries, but it still runs the tests with JUnit 3.

Kevin Wong

unread,
Mar 28, 2011, 11:18:35 AM3/28/11
to usr-ivybeans
Okay, there were two problems here.

First, Commons JXPath 1.2 had a dependency on ant-optional-1.5.1.jar,
which caused the NetBeans ant scripts to run using the JUnit 3.8 test
runner.

Second, ivy-impl.xml was computing the classpath based on every jar it
found in build/jar, and build/jar wasn't being cleaned. So, upgrading
the JXPath dependency to 1.3, which doesn't depend on ant-optional,
didn't fix the problem, unless you knew to also delete ant-
optional-1.5.1.jar from build/jar.

To fix, I upgraded the JXPath dependency to 1.3, and added the
following to build.xml:

<target name="-pre-init" depends="clean-build-libs"/>
<!-- Clean build libs so Ivy doesn't include stale jars in
classpath -->
<target name="clean-build-libs">
<deltree dir="${basedir}/${build.dir}/${lib.dir}"/>
</target>

Bruce Chapman

unread,
Mar 29, 2011, 3:08:09 AM3/29/11
to usr-iv...@googlegroups.com
Hi Kevin,


Thanks for posting your solution.
ivy-impl.xml now does a better job, with more user control of the
classpaths.

We probably need to do a new release to go along with Netbeans 7, so
when you see that you should have better control over what goes into
what classpath.

Bruce

Kevin Wong

unread,
Mar 29, 2011, 11:12:17 AM3/29/11
to usr-ivybeans
Great. I'll look forward to that release.

On Mar 29, 3:08 am, Bruce Chapman <brucechap...@paradise.net.nz>
wrote:
Reply all
Reply to author
Forward
0 new messages