Bug 104517 - Support for running a suite as a session test
Summary: Support for running a suite as a session test
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M1   Edit
Assignee: Rafael Chaves CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 79506 (view as bug list)
Depends on:
Blocks: 70049
  Show dependency tree
 
Reported: 2005-07-20 11:55 EDT by Boris Bokowski CLA
Modified: 2005-08-10 21:05 EDT (History)
1 user (show)

See Also:


Attachments
patch for org.eclipse.core.tests.harness (19.52 KB, patch)
2005-07-25 18:43 EDT, Rafael Chaves CLA
no flags Details | Diff
patch for org.eclipse.core.tests.harness (20.02 KB, patch)
2005-07-26 13:57 EDT, Rafael Chaves CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Bokowski CLA 2005-07-20 11:55:17 EDT
The RCP UI tests currently run with all SDK plug-ins enabled.  This leads to
cases where there are more views, toolbar items, ... than there would be in a
typical RCP app.  For example, in the context of the automated tests, an "empty"
RCP app always has some toolbar items coming from SDK plug-ins, and this makes
it impossible to test cases where you need an empty tool bar.

With help from Rafael, I managed to write a session test that runs with only the
minimal set of RCP plug-ins.  However, this starts an Eclipse instance for every
test case.

We would like to be able to run a whole suite of tests as one session test, but
get the individual test results reported as if the suite had not been run as a
session test.
Comment 1 Rafael Chaves CLA 2005-07-25 18:43:30 EDT
Created attachment 25278 [details]
patch for org.eclipse.core.tests.harness

Adds support for running test suites in a single session. Usage:

SessionTestSuite suite = new SessionTestSuite(<plug-in id>, <suite-class>);
suite.setSharedSession(true);

Restriction: this is the only form of creation supported, and crash tests
(tests that are expected to crash the VM) are not supported.
Comment 2 Boris Bokowski CLA 2005-07-26 11:36:57 EDT
The patch only works if the suite class given has a number of test... methods 
itself.  I would like to use this for all our RCP tests, which means that the 
given suite class will have a suite() method that returns a suite of tests.

If I run my suite, I'm getting a NPE at SessionTestRunner.java:111 which is 
printed on the console, then the tests seem to be executed, but in the end I 
get just one error:

java.lang.Exception: Test did not run
	at org.eclipse.core.tests.session.SessionTestRunner.run
(SessionTestRunner.java:295)
	at org.eclipse.core.tests.session.SessionTestSuite.run
(SessionTestSuite.java:139)
	at org.eclipse.core.tests.session.ConfigurationSessionTestSuite.run
(ConfigurationSessionTestSuite.java:174)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests
(RemoteTestRunner.java:478)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run
(RemoteTestRunner.java:344)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main
(RemotePluginTestRunner.java:57)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run
(CoreTestApplication.java:24)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:376)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
	at org.eclipse.core.launcher.Main.run(Main.java:973)
	at org.eclipse.core.launcher.Main.main(Main.java:948)

Comment 3 Rafael Chaves CLA 2005-07-26 13:57:36 EDT
Created attachment 25314 [details]
patch for org.eclipse.core.tests.harness

I had made some wrong assumptions on how the junit.framework.TestSuite(Class)
constructor works (it does not handle suite() methods).

This new implementation requires the plug-in id constructor to be used (a Class
should *not* be provided), and then the test suite (only one) that is to be run
must be added as an additional step. This test suite can contain other suites.
Example:

SessionTestSuite suite = new SessionTestSuite("org.eclipse.ui.tests.rcp");
suite.addTest(new RcpTestSuite());
suite.setSharedSession(true);

or: 

SessionTestSuite suite = new SessionTestSuite("my.plugin");
suite.addTestSuite(MyTestCase.class);
suite.setSharedSession(true);

Boris, could you give this a try? I will release this as soon we know we won't
have any more i-builds this week.
Comment 4 Rafael Chaves CLA 2005-07-27 11:53:16 EDT
Boris verified the fix works for him.

Released to HEAD.
Comment 5 Rafael Chaves CLA 2005-08-10 21:05:52 EDT
*** Bug 79506 has been marked as a duplicate of this bug. ***