Bug 311979 - Validate/Add Required on junit plug-in launch does not consider both 'application' and 'app to test'
Summary: Validate/Add Required on junit plug-in launch does not consider both 'applica...
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed, noteworthy
: 223678 294415 306750 309251 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-06 17:12 EDT by Curtis Windatt CLA
Modified: 2011-04-04 10:24 EDT (History)
9 users (show)

See Also:


Attachments
Patch for pde.junit.runtime (8.93 KB, patch)
2010-08-04 11:45 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch for pde.junit.runtime (10.30 KB, patch)
2010-08-26 08:19 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch for pde.junit.runtime (9.54 KB, patch)
2011-02-13 15:51 EST, Gunnar Wagenknecht CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Curtis Windatt CLA 2010-05-06 17:12:13 EDT
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).
Comment 1 Curtis Windatt CLA 2010-05-06 17:14:24 EDT
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.
Comment 2 Curtis Windatt CLA 2010-05-06 17:14:29 EDT
*** Bug 309251 has been marked as a duplicate of this bug. ***
Comment 3 Curtis Windatt CLA 2010-05-06 17:14:56 EDT
*** Bug 306750 has been marked as a duplicate of this bug. ***
Comment 4 Curtis Windatt CLA 2010-05-06 17:15:06 EDT
*** Bug 294415 has been marked as a duplicate of this bug. ***
Comment 5 Curtis Windatt CLA 2010-05-06 17:15:14 EDT
*** Bug 223678 has been marked as a duplicate of this bug. ***
Comment 6 Curtis Windatt CLA 2010-05-06 17:20:47 EDT
There isn't realistically time to fix this in 3.6.  Marking for 3.7.
Comment 7 Gunnar Wagenknecht CLA 2010-08-04 03:03:10 EDT
Does this also cover running plug-in JUnit tests without PDE JUnit plug-ins in the target platform?
Comment 8 Gunnar Wagenknecht CLA 2010-08-04 08:31:12 EDT
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?
Comment 9 Curtis Windatt CLA 2010-08-04 10:11:51 EDT
(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.
Comment 10 Gunnar Wagenknecht CLA 2010-08-04 10:31:08 EDT
(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
 ..
Comment 11 Gunnar Wagenknecht CLA 2010-08-04 10:32:54 EDT
(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.
Comment 12 Curtis Windatt CLA 2010-08-04 11:00:03 EDT
(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?
Comment 13 Gunnar Wagenknecht CLA 2010-08-04 11:45:16 EDT
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.
Comment 14 Gunnar Wagenknecht CLA 2010-08-26 08:19:31 EDT
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.
Comment 15 Jeff McAffer CLA 2010-12-13 09:41:16 EST
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?
Comment 16 Jeff McAffer CLA 2011-01-12 14:40:51 EST
status check on this for M5?  still on the table?  This would be very useful to get in IMHO
Comment 17 Curtis Windatt CLA 2011-01-13 10:39:48 EST
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.
Comment 18 Gunnar Wagenknecht CLA 2011-02-13 15:51:31 EST
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
Comment 19 Curtis Windatt CLA 2011-03-03 17:40:15 EST
Fixed in HEAD.  Thank you for the contribution Gunnar.