Search in sources :

Example 1 with TestResults

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