Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Unable to run unit tests(JUnit throws nullpointer exception)
Unable to run unit tests [message #1817647] Wed, 27 November 2019 09:35 Go to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Hello everyone,

I had to reinstall my Eclipse and I cannot run any unit test since.
Version is the same Eclipse CDT 2019-09.

It is strange that even the Hello world example throws the error for me.
I am using JUnit 4 with JavaSE-1.8.

Do you have any idea what is causing this problem? Any feedback is appreciated.

The error:
An internal error occurred during: "Launching MyDslParsingTest".

java.lang.NullPointerException
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localURL(JUnitLaunchConfigurationDelegate.java:715)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.entryString(JUnitLaunchConfigurationDelegate.java:704)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.addEntry(JUnitLaunchConfigurationDelegate.java:691)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:682)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getClasspathAndModulepath(JUnitLaunchConfigurationDelegate.java:631)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getVMRunnerConfiguration(JUnitLaunchConfigurationDelegate.java:196)
	at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launch(JUnitLaunchConfigurationDelegate.java:257)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:860)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:719)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1017)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1220)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Re: Unable to run unit tests [message #1817651 is a reply to message #1817647] Wed, 27 November 2019 10:01 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
i have no idea. maybe you can delete the launch configuration and retry.
or did you use a fresh workspace?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unable to run unit tests [message #1817652 is a reply to message #1817651] Wed, 27 November 2019 10:15 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
I am using a fresh workspace.
Re: Unable to run unit tests [message #1817653 is a reply to message #1817652] Wed, 27 November 2019 10:19 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
no junit installed or in target platform?
https://github.com/eclipse/eclipse.jdt.ui/blob/afb285d86adfc259b684d907eb153a874448ccbc/org.eclipse.jdt.junit.core/src/org/eclipse/jdt/junit/launcher/JUnitLaunchConfigurationDelegate.java#L715


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unable to run unit tests [message #1817654 is a reply to message #1817653] Wed, 27 November 2019 10:36 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Hmmm, strange... Probably you were right.
I have installed the Java Development Tools and now its is working.
I don't know how its was able have JUnit on its build path beforehand.
Re: Unable to run unit tests [message #1817716 is a reply to message #1817654] Thu, 28 November 2019 09:00 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
One problem solved, another raises...

The unit tests of the language are working properly. On the other hand, the unit tests of the UI are still throwing exceptions.

I got a NoClassDefFoundError for org/eclipse/e4/ui/workbench/IWorkbench.
I tried to add the required plug-ins to the dependencies (actually I have added all e4 related plug-ins), but this resulted java.lang.IllegalStateException: Workbench has not been created yet. For this latter I have found inly OSGi related solution on the web, so I guess this is a dead end.

The Xtext AbstractWorkbenchTest requires org/eclipse/ui/IWorkbench, this was the last meaningful point for me. I have no idea why it still requires ../e4/../IWorkbench in spite of this.

Please let me know if you have some solution for this. Thank you!

The stack trace:
java.lang.NoClassDefFoundError: org/eclipse/e4/ui/workbench/IWorkbench
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
	at org.eclipse.xtext.ui.testing.AbstractWorkbenchTest.getWorkbench(AbstractWorkbenchTest.java:95)
	at org.eclipse.xtext.ui.testing.AbstractWorkbenchTest.closeWelcomePage(AbstractWorkbenchTest.java:62)
	at org.eclipse.xtext.ui.testing.AbstractWorkbenchTest.prepareWorkbench(AbstractWorkbenchTest.java:40)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.ClassNotFoundException: org.eclipse.e4.ui.workbench.IWorkbench
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 28 more
Re: Unable to run unit tests [message #1817720 is a reply to message #1817716] Thu, 28 November 2019 09:09 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14667
Registered: July 2009
Senior Member
you need to run such tests as plugin tests

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Unable to run unit tests [message #1817735 is a reply to message #1817720] Thu, 28 November 2019 10:37 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Thank you, that did the trick!

For others with the same struggle:
You need to install Eclipse Plug-in Development Environment also to make it work.
Re: Unable to run unit tests [message #1817738 is a reply to message #1817735] Thu, 28 November 2019 10:56 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

But if you only want to test the Xtext conversions from text to model and model to text, these can be run as standalone tests.

Regards

Ed Willink
Previous Topic:Question: Cross-reference to external model does not return values
Next Topic:How to use multi line in XBlockExpression of a dsl
Goto Forum:
  


Current Time: Fri Apr 26 17:05:20 GMT 2024

Powered by FUDForum. Page generated in 0.03921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top