Java源码示例:com.intellij.execution.testframework.sm.runner.events.TestFinishedEvent
示例1
/**
* 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.getOrDefault(status, "No output found for test target.")
+ " See console output for details",
/* content= */ null,
BlazeComparisonFailureData.NONE,
/* duration= */ 0));
processor.onTestFinished(new TestFinishedEvent(targetName, /*duration=*/ 0L));
processor.onSuiteFinished(new TestSuiteFinishedEvent(label.toString()));
}
示例2
@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;
}
processor.onSuiteStarted(new TestSuiteStartedEvent(suite.getTestCaseName(), null));
for (TestResultsSummary test : suite.getTestResults()) {
final String testName = test.getTestName();
String locationUrl = String.format("java:test://%s.%s", test.getTestCaseName(), testName);
processor.onTestStarted(new TestStartedEvent(testName, locationUrl));
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));
}
processor.onTestFinished(new TestFinishedEvent(testName, test.getTime()));
}
processor.onSuiteFinished(new TestSuiteFinishedEvent(suite.getTestCaseName()));
}
}
示例3
@Nonnull
@Override
public JsonResponse handle(@Nonnull UnityTestStatePostRequest request)
{
UUID uuid = UUID.fromString(request.uuid);
Unity3dTestSession session = Unity3dTestSessionManager.getInstance().findSession(uuid);
if(session == null)
{
return JsonResponse.asError("no session");
}
GeneralTestEventsProcessor processor = session.getProcessor();
ProcessHandler processHandler = session.getProcessHandler();
String name = request.name;
switch(request.type)
{
case TestStarted:
processor.onTestStarted(new TestStartedEvent(name, null));
break;
case TestIgnored:
processor.onTestIgnored(new TestIgnoredEvent(name, StringUtil.notNullize(request.message), request.stackTrace));
break;
case TestFailed:
processor.onTestFailure(new TestFailedEvent(name, StringUtil.notNullize(request.message), request.stackTrace, false, null, null));
break;
case TestOutput:
boolean stdOut = "Log".equals(request.messageType) || "Warning".equals(request.messageType);
StringBuilder builder = new StringBuilder(request.message);
if(!stdOut)
{
builder.append("\n");
String[] strings = StringUtil.splitByLines(request.stackTrace);
for(String line : strings)
{
builder.append(" at ").append(line).append("\n");
}
}
processor.onTestOutput(new TestOutputEvent(name, builder.toString(), stdOut));
break;
case TestFinished:
long time = (long) (request.time * 1000L);
processor.onTestFinished(new TestFinishedEvent(name, time));
break;
case SuiteStarted:
processor.onSuiteStarted(new TestSuiteStartedEvent(name, null));
break;
case SuiteFinished:
processor.onSuiteFinished(new TestSuiteFinishedEvent(name));
break;
case RunFinished:
processor.onFinishTesting();
processHandler.destroyProcess();
break;
}
return JsonResponse.asSuccess(null);
}