Search in sources :

Example 1 with TestSuiteStartedEvent

use of com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent in project buck by facebook.

the class BuckToGeneralTestEventsConverter method consumeTestResultsAvailable.

@Override
public void consumeTestResultsAvailable(long timestamp, TestResults testResults) {
    final GeneralTestEventsProcessor processor = getProcessor();
    if (processor == null) {
        return;
    }
    for (TestCaseSummary suite : testResults.getTestCases()) {
        if (suite.getTestResults().isEmpty()) {
            continue;
        }
        final String locationUrl = null;
        processor.onSuiteStarted(new TestSuiteStartedEvent(suite.getTestCaseName(), locationUrl));
        for (TestResultsSummary test : suite.getTestResults()) {
            final String testName = test.getTestName();
            processor.onTestStarted(new TestStartedEvent(testName, null));
            final String stdOut = test.getStdOut();
            if (stdOut != null) {
                processor.onTestOutput(new TestOutputEvent(testName, stdOut, true));
            }
            final String stdErr = test.getStdErr();
            if (stdErr != null) {
                processor.onTestOutput(new TestOutputEvent(testName, stdErr, false));
            }
            if (test.getType() == ResultType.FAILURE) {
                processor.onTestFailure(new TestFailedEvent(testName, "", test.getStacktrace(), true, null, null));
            } else {
                processor.onTestFinished(new TestFinishedEvent(testName, test.getTime()));
            }
        }
        processor.onSuiteFinished(new TestSuiteFinishedEvent(suite.getTestCaseName()));
    }
}
Also used : TestStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestStartedEvent) GeneralTestEventsProcessor(com.intellij.execution.testframework.sm.runner.GeneralTestEventsProcessor) TestOutputEvent(com.intellij.execution.testframework.sm.runner.events.TestOutputEvent) TestFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestFinishedEvent) TestSuiteStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent) TestCaseSummary(com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestCaseSummary) TestSuiteFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent) TestResultsSummary(com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary) TestFailedEvent(com.intellij.execution.testframework.sm.runner.events.TestFailedEvent)

Example 2 with TestSuiteStartedEvent

use of com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent in project intellij by bazelbuild.

the class BlazeXmlToTestEventsConverter method processTestSuite.

private static void processTestSuite(GeneralTestEventsProcessor processor, BlazeTestEventsHandler eventsHandler, @Nullable Kind kind, TestSuite suite) {
    if (!hasRunChild(suite)) {
        return;
    }
    // only include the innermost 'testsuite' element
    boolean logSuite = !eventsHandler.ignoreSuite(kind, suite);
    if (suite.name != null && logSuite) {
        TestSuiteStarted suiteStarted = new TestSuiteStarted(eventsHandler.suiteDisplayName(kind, suite.name));
        String locationUrl = eventsHandler.suiteLocationUrl(kind, suite.name);
        processor.onSuiteStarted(new TestSuiteStartedEvent(suiteStarted, locationUrl));
    }
    for (TestSuite child : suite.testSuites) {
        processTestSuite(processor, eventsHandler, kind, child);
    }
    for (TestSuite decorator : suite.testDecorators) {
        processTestSuite(processor, eventsHandler, kind, decorator);
    }
    for (TestCase test : suite.testCases) {
        processTestCase(processor, eventsHandler, kind, suite, test);
    }
    if (suite.sysOut != null) {
        processor.onUncapturedOutput(suite.sysOut, ProcessOutputTypes.STDOUT);
    }
    if (suite.sysErr != null) {
        processor.onUncapturedOutput(suite.sysErr, ProcessOutputTypes.STDERR);
    }
    if (suite.name != null && logSuite) {
        processor.onSuiteFinished(new TestSuiteFinishedEvent(eventsHandler.suiteDisplayName(kind, suite.name)));
    }
}
Also used : TestSuiteStarted(jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted) TestSuite(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite) TestCase(com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase) TestSuiteStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent) TestSuiteFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)

Example 3 with TestSuiteStartedEvent

use of com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent in project intellij by bazelbuild.

the class BlazeXmlToTestEventsConverter method reportTargetWithoutOutputFiles.

/**
 * If there are no output files, the test may have failed to build, or timed out. Provide a
 * suitable message in the test UI.
 */
private void reportTargetWithoutOutputFiles(Label label, TestStatus status) {
    if (status == TestStatus.PASSED) {
        // Empty test targets do not produce output XML, yet technically pass. Ignore them.
        return;
    }
    GeneralTestEventsProcessor processor = getProcessor();
    TestSuiteStarted suiteStarted = new TestSuiteStarted(label.toString());
    processor.onSuiteStarted(new TestSuiteStartedEvent(suiteStarted, /*locationUrl=*/
    null));
    String targetName = label.targetName().toString();
    processor.onTestStarted(new TestStartedEvent(targetName, /*locationUrl=*/
    null));
    processor.onTestFailure(getTestFailedEvent(targetName, STATUS_EXPLANATIONS.get(status) + " See console output for details", /*content=*/
    null, /*duration=*/
    0));
    processor.onTestFinished(new TestFinishedEvent(targetName, /*duration=*/
    0L));
    processor.onSuiteFinished(new TestSuiteFinishedEvent(label.toString()));
}
Also used : TestStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestStartedEvent) GeneralTestEventsProcessor(com.intellij.execution.testframework.sm.runner.GeneralTestEventsProcessor) TestSuiteStarted(jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted) TestFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestFinishedEvent) TestSuiteStartedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent) TestSuiteFinishedEvent(com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)

Aggregations

TestSuiteFinishedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)3 TestSuiteStartedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent)3 GeneralTestEventsProcessor (com.intellij.execution.testframework.sm.runner.GeneralTestEventsProcessor)2 TestFinishedEvent (com.intellij.execution.testframework.sm.runner.events.TestFinishedEvent)2 TestStartedEvent (com.intellij.execution.testframework.sm.runner.events.TestStartedEvent)2 TestSuiteStarted (jetbrains.buildServer.messages.serviceMessages.TestSuiteStarted)2 TestCaseSummary (com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestCaseSummary)1 TestResultsSummary (com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary)1 TestCase (com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestCase)1 TestSuite (com.google.idea.blaze.base.run.smrunner.BlazeXmlSchema.TestSuite)1 TestFailedEvent (com.intellij.execution.testframework.sm.runner.events.TestFailedEvent)1 TestOutputEvent (com.intellij.execution.testframework.sm.runner.events.TestOutputEvent)1