Search in sources :

Example 1 with TesterActivator

use of org.eclipse.n4js.tester.internal.TesterActivator in project n4js by eclipse.

the class TesterFrontEnd method computeDerivedValues.

/**
 * Similar to {@link RunnerFrontEnd#computeDerivedValues(RunConfiguration)}, but for testing.
 */
public void computeDerivedValues(TestConfiguration config) {
    // A) compute derived values for the run(!) configuration (will delegate to runner)
    runnerFrontEnd.computeDerivedValues(config, false);
    // B) compute derived values for the test configuration
    // B.1) compute the test tree (note: will create a new session ID every time this is called)
    final TestTree testTree = testDiscoveryHelper.collectTests(config.getUserSelection());
    config.setTestTree(testTree);
    // B.2) pass test tree as execution data
    try {
        // Read out port of running IDE-server and pass it to end-point-computation in tree-transformer
        TesterActivator testerActivator = TesterActivator.getInstance();
        int port = testerActivator != null ? testerActivator.getServerPort() : PORT_PLACEHOLDER_MAGIC_NUMBER;
        config.setResultReportingPort(port);
        testTreeTransformer.setHttpServerPort(Integer.toString(port));
        final String testTreeAsJSON = objectMapper.writeValueAsString(testTreeTransformer.apply(testTree));
        config.setExecutionData(TestConfiguration.EXEC_DATA_KEY__TEST_TREE, testTreeAsJSON);
    } catch (IOException e) {
        e.printStackTrace();
    }
    // B.3) delegate further computation to the specific tester implementation
    ITester tester = testerRegistry.getTester(config);
    tester.prepareConfiguration(config);
}
Also used : IOException(java.io.IOException) TesterActivator(org.eclipse.n4js.tester.internal.TesterActivator) TestTree(org.eclipse.n4js.tester.domain.TestTree)

Aggregations

IOException (java.io.IOException)1 TestTree (org.eclipse.n4js.tester.domain.TestTree)1 TesterActivator (org.eclipse.n4js.tester.internal.TesterActivator)1