Reputation: 861
When I execute this piece of code:
Object[] segments = new Object[2];
segments[0] = // JUnit Test Class 1
segments[1] = // JUnit Test Class 2
TreePath treepath = new TreePath(segments);
TreeSelection treeselection = new TreeSelection(treepath);
JUnitLaunchShortcut j = new JUnitLaunchShortcut();
j.launch(treeselection, ILaunchManager.RUN_MODE);
Eclipse/JUnit Plugin only execute JUnit Test Class 2, perhaps execute the two Test Class but only show at JUnit View the last Test Class (maybe)....
What you think? How can I 'launch' the all Test Class?
Upvotes: 1
Views: 525
Reputation: 61705
As you say in your comment, the JUnit plugin for eclipse doesn't support multiple selections in a configuration. However, the org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate
does support multiple test launching. When you select a project/package/test class in the JUnit plugin, and select Run as JUnit test, it passes the configuration to JUnitLaunchConfigurationDelegate, where it evaluates the tests to be run. If there is one, it calls RemoteTestRunner like this:
RemoteTestRunner -test TestClass
If it finds more than one file, it runs like this:
RemoteTestRunner -testfile testNamesxxxx.txt
where testNamesxxx.test is a file which contains a list of tests to run, for instance:
uk.co.farwell.junit.parameters.ParameterTest
uk.co.farwell.junit.run.AllTests
uk.co.farwell.junit.run.Class1Test
This file is created in your temp directory. So, one possible way to explore is to extend JUnitLaunchConfigurationDelegate and override the evaluateTests method, which has a signature like:
protected IMember[] evaluateTests(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
And you're left with how to communicate the list of tests via the ILaunchConfiguration, but you can extend this for your plugin as well.
Upvotes: 1