When I try to run the JUnit 4 test, I get a NullPointerException in Eclipse. JUnit3 is working.
I am trying to execute the following test class:
import static org.junit.Assert.fail; import org.junit.Test; public class Test { @Test public void test() { fail("Not yet implemented"); } }
Here is the exception stack trace:
java.lang.NullPointerException at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localURL(JUnitLaunchConfigurationDelegate.java:420) at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.entryString(JUnitLaunchConfigurationDelegate.java:409) at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.addEntry(JUnitLaunchConfigurationDelegate.java:396) at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:387) at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getClasspath(JUnitLaunchConfigurationDelegate.java:364) at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launch(JUnitLaunchConfigurationDelegate.java:147) at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855) at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704) at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047) at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
I am using OS X Snow Leopard with Java SDK 1.6.0_35 (from Apple). Both JDK and JUnit 4 are in my build path. Does the Java version have anything to do with the problem?
UPDATE:
OK, I'm an idiot without thinking about it. I installed Eclipse for C / C ++ developers, as I had to do something in C ++. But I also used the same instance for Android for Android with the Android SDK plugin, and I made some small Java applications. But I did not have Java development tools or Java EE developer tools. I installed them now and JUnit 4 is working now.
I think one of these tools is used for JUnit 4. Strange though JUnit 3 worked. In any case, it works now.
Thank you all for your support.
source share