JUnit broken in Netbeans 4.1 RC1
Hmph! It seems that Junit is once again broken in netBeans 4.1 RC1. I downloaded and installed RC1 and opened my nice little project without too much incident. However, now when I try and run a Junit test, I keep getting a class not found error.
Null Test: Caused an ERROR
com.fuzzylizard.util.HibernateUtilTest
java.lang.ClassNotFoundException:
com.fuzzylizard.util.HibernateUtilTest
at java.net.URLClassLoader$1
.run(URLClassLoader.java:199)
at java.security.AccessController
.doPrivileged(Native Method)
at java.net.URLClassLoader
.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader
.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader
.loadClass(Launcher.java:274)
at java.lang.ClassLoader
.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader
.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
This test ran perfectly in netBeans 4.1 Beta. So why should it not run in RC1. Hopefully they will have this fixed for the final version. If anyone knows what is going on here, please let me know.
Update: I solved it. As I looked at this problem more I realized that JUnit wasn’t finding the compiled classes. This means that a directory entry was missing somewhere in Ant. There is a file called project.properties inside of the nbproject directory that contains the following:
build.test.classes.dir=com
build.test.results.dir=
I am not sure what the second entry is for, but the first apparently tells JUnit where to find the compiled test classes. For me, the value was blank. As soon as I entered the value “com”, the directory holding the compiled classes, the tests ran fine.
Update: I just found this bug and a workaround that seems to be related to this problem. According to the bug report it has been fixed.