本文整理汇总了Java中org.junit.platform.engine.TestExecutionResult类的典型用法代码示例。如果您正苦于以下问题:Java TestExecutionResult类的具体用法?Java TestExecutionResult怎么用?Java TestExecutionResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestExecutionResult类属于org.junit.platform.engine包,在下文中一共展示了TestExecutionResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addResult
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
public final Builder addResult(TestIdentifier identifier, TestExecutionResult result) {
DisplayName displayName = getDisplayName(identifier);
if (identifier.isTest()) {
testsBuilder().add(displayName);
}
switch (result.getStatus()) {
case SUCCESSFUL:
successfulBuilder().add(displayName);
return this;
case FAILED:
failuresBuilder().put(displayName, result.getThrowable().orElse(null));
return this;
default:
throw new AssertionError("Unhandled case in enum: " + result.getStatus());
}
}
示例2: testWithExpectedException_successfulTest_fails
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@org.junit.jupiter.api.Test
void testWithExpectedException_successfulTest_fails() {
ExecutionEventRecorder eventRecorder = executeTests(TestTestCase.class,
"testWithExpectedException_successfulTest");
assertThat(eventRecorder.getTestStartedCount()).isEqualTo(1);
assertThat(eventRecorder.getTestFailedCount()).isEqualTo(1);
//@formatter:off
Optional<String> failedTestMessage = eventRecorder
.getFailedTestFinishedEvents().get(0)
.getPayload(TestExecutionResult.class)
.flatMap(TestExecutionResult::getThrowable)
.map(Throwable::getMessage);
//@formatter:on
String expectedMessage = format(EXPECTED_EXCEPTION_WAS_NOT_THROWN, IllegalArgumentException.class);
assertThat(failedTestMessage).contains(expectedMessage);
}
示例3: testWithExpectedException_exceptionThrownOfSupertype_fails
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@org.junit.jupiter.api.Test
void testWithExpectedException_exceptionThrownOfSupertype_fails() {
ExecutionEventRecorder eventRecorder = executeTests(TestTestCase.class,
"testWithExpectedException_exceptionThrownOfSupertype");
assertThat(eventRecorder.getTestStartedCount()).isEqualTo(1);
assertThat(eventRecorder.getTestFailedCount()).isEqualTo(1);
//@formatter:off
Optional<Throwable> failedTestThrowable = eventRecorder
.getFailedTestFinishedEvents().get(0)
.getPayload(TestExecutionResult.class)
.flatMap(TestExecutionResult::getThrowable);
//@formatter:on
assertThat(failedTestThrowable).containsInstanceOf(RuntimeException.class);
}
示例4: testWithTimeout_exceedsTimeout_fails
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@org.junit.jupiter.api.Test
void testWithTimeout_exceedsTimeout_fails() throws Exception {
ExecutionEventRecorder eventRecorder = executeTests(TestTestCase.class, "testWithTimeout_exceedsTimeout");
assertThat(eventRecorder.getTestStartedCount()).isEqualTo(1);
assertThat(eventRecorder.getTestFailedCount()).isEqualTo(1);
//@formatter:off
Optional<String> failedTestMessage = eventRecorder
.getFailedTestFinishedEvents().get(0)
.getPayload(TestExecutionResult.class)
.flatMap(TestExecutionResult::getThrowable)
.map(Throwable::getMessage);
String expectedMessage = String.format(
TimeoutExtension.TEST_RAN_TOO_LONG, "testWithTimeout_exceedsTimeout()", 1, 10);
//@formatter:on
// the message contains the actual run time, which is unpredictable, so it has to be cut off for the assertion
String expectedKnownPrefix = expectedMessage.substring(0, expectedMessage.length() - 6);
assertThat(failedTestMessage).isNotEmpty();
assertThat(failedTestMessage.get()).startsWith(expectedKnownPrefix);
}
示例5: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(final TestIdentifier testIdentifier, final TestExecutionResult testExecutionResult) {
if (testIdentifier.isTest()) {
final String uuid = tests.get();
tests.remove();
getLifecycle().updateTestCase(uuid, result -> {
result.setStage(Stage.FINISHED);
switch (testExecutionResult.getStatus()) {
case FAILED:
testExecutionResult.getThrowable().ifPresent(throwable -> {
result.setStatus(getStatus(throwable));
result.setStatusDetails(ResultsUtils.getStatusDetails(throwable).orElse(null));
});
break;
case SUCCESSFUL:
result.setStatus(PASSED);
break;
default:
result.setStatus(SKIPPED);
testExecutionResult.getThrowable().ifPresent(throwable ->
result.setStatusDetails(ResultsUtils.getStatusDetails(throwable).orElse(null))
);
break;
}
});
getLifecycle().stopTestCase(uuid);
getLifecycle().writeTestCase(uuid);
}
}
示例6: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
super.executionFinished(testIdentifier, testExecutionResult);
if (testIdentifier.isTest()) {
Status status = testExecutionResult.getStatus();
Color color = Color.valueOf(status);
printMessage(color, STATUS + status);
printFailureMessage(testIdentifier, testExecutionResult, color);
System.out.println();
}
}
示例7: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) {
Optional<Throwable> throwable = testExecutionResult.getThrowable();
if (throwable.isPresent()) {
throw new UndeclaredThrowableException(throwable.get());
}
}
示例8: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
Map<String, Object> data = new HashMap<>();
data.put("type", "executionFinished");
data.put("success", testExecutionResult.getStatus() == TestExecutionResult.Status.SUCCESSFUL);
data.put("throwable", testExecutionResult.getThrowable().orElse(null));
writeData(testIdentifier, data);
}
示例9: execute
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void execute(ExecutionRequest request) {
TestDescriptor engine = request.getRootTestDescriptor();
EngineExecutionListener listener = request.getEngineExecutionListener();
listener.executionStarted(engine);
for (TestDescriptor child : engine.getChildren()) {
listener.executionStarted(child);
listener.executionFinished(child, TestExecutionResult.successful());
}
listener.executionFinished(engine, TestExecutionResult.successful());
}
示例10: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestIdentifier testIdentifier,
TestExecutionResult testExecutionResult) {
executionReportBuilder.addResult(testIdentifier, testExecutionResult);
}
示例11: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult result) {
addEvent(ExecutionEvent.executionFinished(testDescriptor, result));
}
示例12: getFinishedEventsByStatus
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
public Stream<ExecutionEvent> getFinishedEventsByStatus(Status status) {
return getEventsByType(FINISHED)
.filter(
byPayload(
TestExecutionResult.class, where(TestExecutionResult::getStatus, isEqual(status))));
}
示例13: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
public static ExecutionEvent executionFinished(
TestDescriptor testDescriptor, TestExecutionResult result) {
return new ExecutionEvent(FINISHED, testDescriptor, result);
}
示例14: printFailureMessage
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
private void printFailureMessage(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult, Color color) {
if (testExecutionResult.getStatus().equals(Status.FAILED)) {
testExecutionResult.getThrowable()
.ifPresent(throwable -> printMessage(color, throwable.toString()));
}
}
示例15: executionFinished
import org.junit.platform.engine.TestExecutionResult; //导入依赖的package包/类
@Override
public void executionFinished(TestDescriptor testDescriptor, TestExecutionResult testExecutionResult) {
allTestsPassed = allTestsPassed && testExecutionResult.getStatus() == SUCCESSFUL;
}