Community
Participate
Working Groups
1) Open a new junit plug-in launch configuration and select a test that can run headless 2) Uncheck run in UI thread 3) Set the application to [No Application] 4) Open the plug-ins tab, deselect all 5) Check a non-UI plug-in 6) Hit select all required 7) Hit validate (everything should be good to go) 8) Launch Result: Launch fails because it can't find the "org.eclipse.pde.junit.runtime.nonuithreadtestapplication" application. The above steps will illustrate the problem, but there are other configurations that can have the same result. In Eclipse Launch configs there is a single application to launch. In JUnit Plug-in configs there can be two applications to launch -application and -testApplication. The plugins tab only checks -application when validating and adding required plug-ins. The solution is not as straightforward as checking both applications during validate. When the "Run in UI thread" checkbox is unchecked, only -application is set, but the launch delegate will change the attributes. The solution is probably to move the logic from the delegate to the Main Tab (which we are already subclassing).
One weird behaviour that this bug causes is that running in the non-UI thread actually forces the Eclipse UI to be launched. This is because "org.eclipse.pde.junit.runtime.nonuithreadtestapplication" is provided by pde.junit.runtime which depends on jdt.junit.runtime which depends on eclipse.ui.
*** Bug 309251 has been marked as a duplicate of this bug. ***
*** Bug 306750 has been marked as a duplicate of this bug. ***
*** Bug 294415 has been marked as a duplicate of this bug. ***
*** Bug 223678 has been marked as a duplicate of this bug. ***
There isn't realistically time to fix this in 3.6. Marking for 3.7.
Does this also cover running plug-in JUnit tests without PDE JUnit plug-ins in the target platform?
I looked a bit further because I'm having issues with running headless plug-in tests. I think there is a misconception between "non UI thread" and true headless plug-in tests. NonUIThreadTestApplication extends UITestApplication which requires org.eclipse.ui.testing.* stuff. Thus, even if the org.eclipse.ui dependencies are optional it's currently impossible run true headless plug-in tests. However, looking at the launch implementation, the NonUIThreadTestApplication will ignore any configured application. At runtime CoreTestApplication will always be executed. Shouldn't there be a real true headless OSGi JUnit launch configuration type which doesn't depend on any org.eclipe.ui.* stuff in your target platform?
(In reply to comment #8) In 3.6 we fixed some of the junit launching code so that selecting 'no application' did not require UI plugins to validate/launch (bug 309860). If you are using an application, UI plug-ins are required (all the applications belong to a ui plug-in). This is true even if you select the 'run in non ui thread' option. If you want applications like the nonUIThreadApplication to be separate from the UI, please file a separate bug (changing that would require restructuring the junit plug-ins). This bug deals with when you are launching headless (no application) and check run in non-ui thread. In that case, even though we have selected no application, the nonuithreadapplication is launched.
(In reply to comment #9) > [...] This bug deals with when you are launching > headless (no application) and check run in non-ui thread. In that case, even > though we have selected no application, the nonuithreadapplication is launched. Should the nonuithreadapplication not be launched in this case? The thing is, I have an OSGi bundle and another bundle containing some tests. I also have the 'org.eclipse.pde.junit.runtime.standalone.feature.group' in my target platform (from Helios EclipseRT category). However, I'm unable to launch the tests because of: !ENTRY org.eclipse.osgi 4 0 ... !MESSAGE Application error !STACK 1 org.eclipse.core.runtime.CoreException: Plug-in org.eclipse.pde.junit.runtime was unable to load class org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication. .. Caused by: java.lang.NoClassDefFoundError: org/eclipse/ui/testing/ITestHarness .. Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.testing.ITestHarness ..
(In reply to comment #10) > The thing is, I have an OSGi bundle and another bundle containing some tests. I > also have the 'org.eclipse.pde.junit.runtime.standalone.feature.group' in my > target platform (from Helios EclipseRT category). However, I'm unable to launch > the tests because of: Note, when I modify NonUIThreadTestApplication to not depend on org.eclipse.ui.testing.* stuff it works flawlessly.
(In reply to comment #10) > Should the nonuithreadapplication not be launched in this case? It depends on the application that is being run. If you have [no application] selected, then we shouldn't (we don't want any UI). If you have an application selected, yes we should (we are running a workbench application with tests running in a non-UI thread). (In reply to comment #11) > Note, when I modify NonUIThreadTestApplication to not depend on > org.eclipse.ui.testing.* stuff it works flawlessly. How did you modify it?
Created attachment 175843 [details] Patch for pde.junit.runtime (In reply to comment #12) > (In reply to comment #11) > > Note, when I modify NonUIThreadTestApplication to not depend on > > org.eclipse.ui.testing.* stuff it works flawlessly. > > How did you modify it? I basically switched the inheritance level. So that it doesn't depend on the UI testing stuff anymore.
Created attachment 177521 [details] Patch for pde.junit.runtime Re-uploaded patch, should now apply cleanly on a fresh checkout from HEAD. Note, similar to other PDE plug-ins there are some formattings/save actions enabled which cause additional code modifications.
Initial review of the patch looks reasonable. I've not done any testing but the approach makes sense. Moreover the problem is useful to fix. Application != need UI. For example, the IDE ships with more headless application extensions than UI application extensions. Curtis, can we get this on for M5?
status check on this for M5? still on the table? This would be very useful to get in IMHO
I have other items on my plate right now. I will still find time to review in 3.7, I just can't promise M5.
Created attachment 188855 [details] Patch for pde.junit.runtime Updated patch to current HEAD. This also changes the cardinality of the non-UI thread test application to 1 instead of singleton-global. Now it's possible to actually test real headless OSGi applications
Fixed in HEAD. Thank you for the contribution Gunnar.