Search in sources :

Example 1 with TestResultsSummary

use of com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary 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 TestResultsSummary

use of com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary in project buck by facebook.

the class BuckEventsConsumer method showTestResults.

public void showTestResults() {
    if (!mTestResultsList.isEmpty() && !BuckToolWindowFactory.isToolWindowVisible(mProject)) {
        BuckToolWindowFactory.showToolWindow(mProject);
    }
    float duration = (mTestingEndTimestamp - mTestingStartTimestamp) / 1000;
    final StringBuilder message = new StringBuilder("Testing ended, took " + duration + " seconds!\n");
    for (TestResults testResults : mTestResultsList) {
        for (TestCaseSummary testCaseSummary : testResults.getTestCases()) {
            long time = testCaseSummary.getTotalTime();
            String formattedTime;
            if (time >= 1000) {
                formattedTime = (time / 1000 + time % 1000) + "s";
            } else {
                formattedTime = time + "ms";
            }
            if (testCaseSummary.isSuccess() == true) {
                message.append("PASS  " + formattedTime + "  " + testCaseSummary.getTestResults().size() + " passed  " + testCaseSummary.getTestCaseName() + "\n");
            } else {
                int failureCount = 0;
                StringBuilder failureMessage = new StringBuilder();
                for (TestResultsSummary testResultSummary : testCaseSummary.getTestResults()) {
                    if (!testResultSummary.isSuccess()) {
                        failureMessage.append(testResultSummary.getStacktrace() + "\n");
                        failureCount++;
                    }
                }
                message.append("FAILED  " + formattedTime + "  " + (testCaseSummary.getTestResults().size() - failureCount) + " passed  " + failureCount + " failed  " + testCaseSummary.getTestCaseName() + "\n");
                message.append(failureMessage);
            }
        }
    }
    BuckEventsConsumer.this.mTestResults.setDetail(message.toString());
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            BuckEventsConsumer.this.mTreeModel.reload();
        }
    });
    mTestResultsList.clear();
}
Also used : TestCaseSummary(com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestCaseSummary) TestResults(com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResults) TestResultsSummary(com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary)

Aggregations

TestCaseSummary (com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestCaseSummary)2 TestResultsSummary (com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResultsSummary)2 TestResults (com.facebook.buck.intellij.ideabuck.ws.buckevents.parts.TestResults)1 GeneralTestEventsProcessor (com.intellij.execution.testframework.sm.runner.GeneralTestEventsProcessor)1 TestFailedEvent (com.intellij.execution.testframework.sm.runner.events.TestFailedEvent)1 TestFinishedEvent (com.intellij.execution.testframework.sm.runner.events.TestFinishedEvent)1 TestOutputEvent (com.intellij.execution.testframework.sm.runner.events.TestOutputEvent)1 TestStartedEvent (com.intellij.execution.testframework.sm.runner.events.TestStartedEvent)1 TestSuiteFinishedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteFinishedEvent)1 TestSuiteStartedEvent (com.intellij.execution.testframework.sm.runner.events.TestSuiteStartedEvent)1