Search in sources :

Example 1 with Result

use of io.cucumber.plugin.event.Result 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)));
}
Also used : Status(io.cucumber.plugin.event.Status) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 2 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class ResultTest method failed_result_is_not_ok.

@Test
void failed_result_is_not_ok() {
    Result failedResult = new Result(FAILED, ZERO, null);
    assertFalse(failedResult.getStatus().isOk());
}
Also used : Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 3 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class ResultTest method severity_from_low_to_high_is_passed_skipped_pending_undefined_ambiguous_failed.

@Test
void severity_from_low_to_high_is_passed_skipped_pending_undefined_ambiguous_failed() {
    Result passed = new Result(PASSED, ZERO, null);
    Result skipped = new Result(SKIPPED, ZERO, null);
    Result pending = new Result(PENDING, ZERO, null);
    Result ambiguous = new Result(AMBIGUOUS, ZERO, null);
    Result undefined = new Result(UNDEFINED, ZERO, null);
    Result failed = new Result(FAILED, ZERO, null);
    List<Result> results = asList(pending, passed, skipped, failed, ambiguous, undefined);
    results.sort(Comparator.comparing(Result::getStatus));
    assertThat(results, equalTo(asList(passed, skipped, pending, undefined, ambiguous, failed)));
}
Also used : Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 4 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class UnusedStepsSummaryPrinterTest method verifyUnusedStepsPrinted.

@Test
void verifyUnusedStepsPrinted() {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    UnusedStepsSummaryPrinter summaryPrinter = new UnusedStepsSummaryPrinter(out);
    summaryPrinter.setMonochrome(true);
    TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    summaryPrinter.setEventPublisher(bus);
    // Register two steps, use one, then finish the test run
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/belly.feature:3", "a few cukes")));
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/tummy.feature:5", "some more cukes")));
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/gut.feature:7", "even more cukes")));
    bus.send(new TestStepFinished(bus.getInstant(), mock(TestCase.class), mockTestStep("my/belly.feature:3"), new Result(Status.UNUSED, Duration.ZERO, null)));
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/belly.feature:3", "a few cukes")));
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/tummy.feature:5", "some more cukes")));
    bus.send(new StepDefinedEvent(bus.getInstant(), mockStepDef("my/gut.feature:7", "even more cukes")));
    bus.send(new TestStepFinished(bus.getInstant(), mock(TestCase.class), mockTestStep("my/gut.feature:7"), new Result(Status.UNUSED, Duration.ZERO, null)));
    bus.send(new TestRunFinished(bus.getInstant(), new Result(Status.PASSED, Duration.ZERO, null)));
    // Verify produced output
    assertThat(out, isBytesEqualTo("1 Unused steps:\n" + "my/tummy.feature:5 # some more cukes\n"));
}
Also used : TimeServiceEventBus(io.cucumber.core.runtime.TimeServiceEventBus) StepDefinedEvent(io.cucumber.plugin.event.StepDefinedEvent) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) ByteArrayOutputStream(java.io.ByteArrayOutputStream) UUID(java.util.UUID) TestRunFinished(io.cucumber.plugin.event.TestRunFinished) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Example 5 with Result

use of io.cucumber.plugin.event.Result in project cucumber-jvm by cucumber.

the class PickleStepTestStepTest method result_is_result_from_step_when_step_hook_does_not_pass.

@Test
void result_is_result_from_step_when_step_hook_does_not_pass() throws Throwable {
    RuntimeException runtimeException = new RuntimeException();
    Result failure = new Result(Status.FAILED, ZERO, runtimeException);
    doThrow(runtimeException).when(definitionMatch).runStep(any(TestCaseState.class));
    ExecutionMode nextExecutionMode = step.run(testCase, bus, state, ExecutionMode.RUN);
    assertThat(nextExecutionMode, is(ExecutionMode.SKIP));
    assertThat(state.getStatus(), is(equalTo(FAILED)));
    ArgumentCaptor<TestCaseEvent> captor = forClass(TestCaseEvent.class);
    verify(bus, times(12)).send(captor.capture());
    List<TestCaseEvent> allValues = captor.getAllValues();
    assertThat(((TestStepFinished) allValues.get(6)).getResult(), is(equalTo(failure)));
}
Also used : TestCaseEvent(io.cucumber.plugin.event.TestCaseEvent) Result(io.cucumber.plugin.event.Result) Test(org.junit.jupiter.api.Test)

Aggregations

Result (io.cucumber.plugin.event.Result)56 Test (org.junit.jupiter.api.Test)41 TestStepFinished (io.cucumber.plugin.event.TestStepFinished)29 TestCaseFinished (io.cucumber.plugin.event.TestCaseFinished)26 TestCaseStarted (io.cucumber.plugin.event.TestCaseStarted)15 TestStepStarted (io.cucumber.plugin.event.TestStepStarted)14 Test (org.testng.annotations.Test)9 UUID (java.util.UUID)7 Failure (org.junit.runner.notification.Failure)7 SkipException (org.testng.SkipException)7 PickleStepTestStep (io.cucumber.plugin.event.PickleStepTestStep)6 Status (io.cucumber.plugin.event.Status)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 List (java.util.List)6 TestAbortedException (org.opentest4j.TestAbortedException)6 EventBus (io.cucumber.core.eventbus.EventBus)5 SnippetsSuggestedEvent (io.cucumber.plugin.event.SnippetsSuggestedEvent)5 Suggestion (io.cucumber.plugin.event.SnippetsSuggestedEvent.Suggestion)5 TestRunFinished (io.cucumber.plugin.event.TestRunFinished)5 OutputStream (java.io.OutputStream)5