When running junit, it fail, with an "caused an error". Reproducible: Always Steps to Reproduce: run a junit test inside netbeans. Actual Results: The test return the followin result: Testcase: initializationError(simplejunittestproject.TestClassTest): Caused an ERROR org/hamcrest/SelfDescribing java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Expected Results: The test should succed I will attach a simple test program, which fails when running the junit test.
Created attachment 184252 [details] A simple netbeans projekt, with one class, and one junit test that fails.
Reassigning to java herd.
Our netbeans uses symlink to junit-4 jar which does not contain hamcrest classes, these are part of hamcrest-core and hamcrest packages. Simply add one of these to you project's test classpath and the tests should not fail. Junit creates two releases: http://sourceforge.net/project/shownotes.php?release_id=618683&group_id=15278 We create the one that is just junit, no extra classes from different projects whereas netbeans uses the other one. I also grepped the netbeans tree to find out whether I can inject hamcrest jar there so it would be added to classpath along with junit-4 but that would mean to create modified org.netbeans.libs.junit4 module and once this module would be updated through update center, the behavior would return to the one that is now so it makes no sense to do it. The other way is to create junit-4 jar that contains hamcrest but that's against how java packages are packaged. So adding hamcrest to the project's test classpath (if needed, not all junit tests need hamcrest) is the only solution imo.