Ok, I'm upset! I hunted around for hours, and I'm still at a standstill.
Environment: WinXP, Eclipse Galileo 3.5 (direct installation - no additional plugins).
So, I have a simple JUnit test. It works great from within the internal configuration of Eclipse JUnit. This class has nothing to do with anything. To minimize this problem, it simply contains:
@Test public void testX() { assertEquals("1", new Integer(1).toString()); }
No sweat yet. Now I want to take the super-advanced step of launching this test case from Ant (the final goal is integration with Hudson).
So, I create a build.xml file:
<project name="Test" default="basic"> <property name="default.target.dir" value="${basedir}/target" /> <property name="test.report.dir" value="${default.target.dir}/test-reports" /> <target name="basic"> <mkdir dir="${test.report.dir}" /> <junit fork="true" printSummary="true" showOutput="true"> <formatter type="plain" /> <classpath> <pathelement path="${basedir}/bin "/> </classpath> <batchtest fork="true" todir="${test.report.dir}" > <fileset dir="${basedir}/bin"> <include name="**/*Test.*" /> </fileset> </batchtest> </junit> </target> </project>
$ {basedir} is the name of the Java project in the workspace that contains the source code, classes, and assembly file. All .java and build.xml are in $ {basedir} / src. The .class files are in $ {basedir} / bin.
I added eclipse-install-dir / plugins / org.junit4_4.5.0.v20090423 / junit.jar to the Ant Runtime Classpath via Windows / Preferences / Ant / Runtime / Contributed Entries. ant -junit.jar is in Ant Home Entries.
So what happens when I launch this insanely challenging goal? My report file contains:
Testsuite: com.xyz.test.RussianTest Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec Testcase: initializationError took 0 sec Caused an ERROR org/hamcrest/SelfDescribing java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What is this org.hamcrest.SelfDescribing class? Do something with ridicule? Good. But why addiction? I do nothing with this. This is literally a Java project without dependencies other than JUnit.
Inserted (and upset) !!
java classpath junit ant hamcrest
SteveT Jul 23 '09 at 11:56 2009-07-23 11:56
source share