Skip to content

Commit

Permalink
TYCHO-326 Run SWTBot tests
Browse files Browse the repository at this point in the history
Changed UI test harness to allow execution of tests from non-ui thread
Added three new parameters to osgi test mojo, useUIThread, testApplication and testProduct
  • Loading branch information
ifedorenko committed Dec 18, 2009
1 parent 235de3d commit 0e05735
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 16 deletions.
Expand Up @@ -146,6 +146,22 @@ public class TestMojo extends AbstractMojo {
*/
private Dependency[] dependencies;

/**
* Eclipse application to be run. If not specified, default application
* org.eclipse.ui.ide.workbench will be used.
*
* @parameter
*/
private String testApplication;

/**
* Eclipse product to be run. Despite the name, regular -product parameter
* will be used to start Eclipse.
*
* @parameter
*/
private String testProduct;

private BundleResolutionState bundleResolutionState;

/**
Expand All @@ -155,9 +171,21 @@ public class TestMojo extends AbstractMojo {
*/
private MavenSession session;

/** @parameter default-value="false" */
/**
* Run tests using UI (true) or headless (false) test harness.
*
* @parameter default-value="false"
*/
private boolean useUIHarness;

/**
* Run tests in UI (true) or background (false) thread. Only applies to
* UI test harness.
*
* @parameter default-value="true"
*/
private boolean useUIThread;

/**
* @parameter expression="${plugin.artifacts}"
*/
Expand Down Expand Up @@ -449,6 +477,21 @@ private boolean runTest(TestEclipseRuntime testRuntime, String testBundle, Strin
"-application", getTestApplication(testRuntime),
"-testproperties", surefireProperties.getAbsolutePath(),
});
if (testApplication != null) {
cli.addArguments(new String[] {
"-testApplication", testApplication,
});
}
if (testProduct != null) {
cli.addArguments(new String[] {
"-product", testProduct,
});
}
if (useUIHarness && !useUIThread) {
cli.addArguments(new String[] {
"-nouithread",
});
}
if (appArgLine != null) {
Arg appArg = cli.createArg();
appArg.setLine(appArgLine);
Expand Down
Expand Up @@ -16,22 +16,42 @@ public abstract class AbstractUITestApplication implements ITestHarness {
private String[] fArgs = new String[0];
private TestableObject fTestableObject;

public void runTests() {
fTestableObject.testingStarting();
fTestableObject.runTest(new Runnable() {
public void run() {
try {
fTestRunnerResult = OsgiSurefireBooter.run(fArgs);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
fTestableObject.testingFinished();
}
public void runTests() {
fTestableObject.testingStarting();
if (useUIThread(fArgs)) {
fTestableObject.runTest(new Runnable() {
public void run() {
try {
fTestRunnerResult = OsgiSurefireBooter.run(fArgs);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
} else {
try {
fTestRunnerResult = OsgiSurefireBooter.run(fArgs);
} catch ( Exception e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
fTestableObject.testingFinished();
}

private boolean useUIThread(String[] args) {
if (args != null) {
for (int i = 0; i < args.length; i++) {
if ("-nouithread".equals(args[i])) {
return false;
}
}
}
return true;
}

/*
/*
* return the application to run, or null if not even the default application
* is found.
*/
Expand Down

0 comments on commit 0e05735

Please sign in to comment.