use of org.eclipse.n4js.tester.TestConfiguration in project n4js by eclipse.
the class AbstractTesterLaunchShortcut method launchTest.
/**
* Launch a test of the given URI (may point to project, folder, file).
*/
protected void launchTest(URI resourceToTest, String mode) {
TestConfiguration testConfig = testerFrontEnd.createConfiguration(getTesterId(), null, resourceToTest);
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID());
DebugUITools.launch(testConfigConverter.toLaunchConfiguration(type, testConfig), mode);
// execution dispatched to proper ILaunchConfigurationDelegate
}
use of org.eclipse.n4js.tester.TestConfiguration in project n4js by eclipse.
the class TestResultsView method performRelaunch.
/**
* Invoked when user performs {@link #actionRelaunch}.
*/
protected void performRelaunch() {
if (null != currentRoot) {
final TestSession session = from(registeredSessions).firstMatch(s -> s.root == currentRoot).orNull();
if (null != session) {
final TestConfiguration configurationToReRun = session.configuration;
registeredSessions.remove(session);
try {
final TestConfiguration newConfiguration = testerFrontEnd.createConfiguration(configurationToReRun);
testerFrontEndUI.runInUI(newConfiguration);
} catch (Exception e) {
String message = "Test class not found in the workspace.";
if (!Strings.isNullOrEmpty(e.getMessage())) {
message += " Reason: " + e.getMessage();
}
MessageDialog.openError(getShell(), "Cannot open editor", message);
}
}
}
}
use of org.eclipse.n4js.tester.TestConfiguration in project n4js by eclipse.
the class HeadlessTester method runTests.
/**
* Actually start the requested tester to test provided location. Workspace from headlesCompiler should be
* configured before calling this method.
*
* @param tester
* the tester to be used
* @param implementationId
* to be used for API-IMPL projects
* @param locationToTest
* location of the test code
* @throws ExitCodeException
* in cases of errors
*/
public void runTests(String tester, String implementationId, URI locationToTest, File testReportRoot) throws ExitCodeException {
ITesterDescriptor testerDescriptor = checkTester(tester);
logger.info("Using tester :" + testerDescriptor.getId());
TestConfiguration testConfiguration = null;
try {
testConfiguration = testerFrontEnd.createConfiguration(testerDescriptor.getId(), implementationId, locationToTest);
} catch (java.lang.IllegalStateException e2) {
logger.error(Throwables.getStackTraceAsString(e2));
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "Cannot create test configuration.", e2);
}
try {
TestTree testTree = testConfiguration.getTestTree();
LoggingTestListener testListener = new LoggingTestListener(testerEventBus, logger, testTree);
Process process = testerFrontEnd.test(testConfiguration);
int exit = process.waitFor();
if (!testListener.finished())
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "Test session has not finished.");
if (testReportRoot != null)
createTestReport(testReportRoot, testTree);
if (!testListener.isOK())
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "There were test errors, see console logs and/or test report for details.");
if (exit != 0)
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "The spawned tester '" + testerDescriptor.getId() + "' exited with code=" + exit);
} catch (InterruptedException e1) {
logger.error(Throwables.getStackTraceAsString(e1));
throw new ExitCodeException(EXITCODE_TESTER_STOPPED_WITH_ERROR, "The spawned tester exited by throwing an exception", e1);
} finally {
testerFacade.shutdownFramework();
}
}
Aggregations