use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.
the class ResultTest method is_query_returns_true_for_the_status_of_the_result_object.
@Test
void is_query_returns_true_for_the_status_of_the_result_object() {
int checkCount = 0;
for (Status status : Status.values()) {
Result result = new Result(status, ZERO, null);
assertTrue(result.getStatus().is(result.getStatus()));
checkCount += 1;
}
assertThat("No checks performed", checkCount > 0, is(equalTo(true)));
}
use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.
the class TestStep method run.
ExecutionMode run(TestCase testCase, EventBus bus, TestCaseState state, ExecutionMode executionMode) {
Instant startTime = bus.getInstant();
emitTestStepStarted(testCase, bus, state.getTestExecutionId(), startTime);
Status status;
Throwable error = null;
try {
status = executeStep(state, executionMode);
} catch (Throwable t) {
rethrowIfUnrecoverable(t);
error = t;
status = mapThrowableToStatus(t);
}
Instant stopTime = bus.getInstant();
Duration duration = Duration.between(startTime, stopTime);
Result result = mapStatusToResult(status, error, duration);
state.add(result);
emitTestStepFinished(testCase, bus, state.getTestExecutionId(), stopTime, duration, result);
return result.getStatus().is(Status.PASSED) ? executionMode : SKIP;
}
use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.
the class ResultTest method is_query_returns_false_for_statuses_different_from_the_status_of_the_result_object.
@Test
void is_query_returns_false_for_statuses_different_from_the_status_of_the_result_object() {
int checkCount = 0;
for (Status resultStatus : Status.values()) {
Result result = new Result(resultStatus, ZERO, null);
for (Status status : Status.values()) {
if (status != resultStatus) {
assertFalse(result.getStatus().is(status));
checkCount += 1;
}
}
}
assertThat("No checks performed", checkCount > 0, is(equalTo(true)));
}
use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.
the class TeamCityPlugin method printTestStepFinished.
private void printTestStepFinished(TestStepFinished event) {
String timeStamp = extractTimeStamp(event);
long duration = extractDuration(event.getResult());
String name = extractName(event.getTestStep());
Throwable error = event.getResult().getError();
Status status = event.getResult().getStatus();
switch(status) {
case SKIPPED:
{
String message = error == null ? "Step skipped" : error.getMessage();
print(TEMPLATE_TEST_IGNORED, timeStamp, duration, message, name);
break;
}
case PENDING:
{
String details = error == null ? "" : error.getMessage();
print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step pending", details, name);
break;
}
case UNDEFINED:
{
String snippets = getSnippets(currentTestCase);
print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step undefined", snippets, name);
break;
}
case AMBIGUOUS:
case FAILED:
{
String details = printStackTrace(error);
print(TEMPLATE_TEST_FAILED, timeStamp, duration, "Step failed", details, name);
break;
}
default:
break;
}
print(TEMPLATE_TEST_FINISHED, timeStamp, duration, name);
}
use of io.cucumber.plugin.event.Status in project cucumber-jvm by cucumber.
the class TestCase method run.
void run(EventBus bus) {
ExecutionMode nextExecutionMode = this.executionMode;
emitTestCaseMessage(bus);
Instant start = bus.getInstant();
UUID executionId = bus.generateId();
emitTestCaseStarted(bus, start, executionId);
TestCaseState state = new TestCaseState(bus, executionId, this);
for (HookTestStep before : beforeHooks) {
nextExecutionMode = before.run(this, bus, state, executionMode).next(nextExecutionMode);
}
for (PickleStepTestStep step : testSteps) {
nextExecutionMode = step.run(this, bus, state, nextExecutionMode).next(nextExecutionMode);
}
for (HookTestStep after : afterHooks) {
nextExecutionMode = after.run(this, bus, state, executionMode).next(nextExecutionMode);
}
Instant stop = bus.getInstant();
Duration duration = Duration.between(start, stop);
Status status = Status.valueOf(state.getStatus().name());
Result result = new Result(status, duration, state.getError());
emitTestCaseFinished(bus, executionId, stop, duration, status, result);
}
Aggregations