cucumber.api.event.TestStepStarted Java Examples

The following examples show how to use cucumber.api.event.TestStepStarted. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void handleTestStepStarted(final TestStepStarted event) {
    if (!event.testStep.isHook()) {
        final String stepKeyword = Optional.ofNullable(
                cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, event.testStep.getStepLine())
        ).orElse("UNDEFINED");

        final StepResult stepResult = new StepResult()
                .setName(String.format("%s %s", stepKeyword, event.testStep.getPickleStep().getText()))
                .setStart(System.currentTimeMillis());

        lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(event.testStep), stepResult);

        event.testStep.getStepArgument().stream()
                .filter(PickleTable.class::isInstance)
                .findFirst()
                .ifPresent(table -> createDataTableAttachment((PickleTable) table));
    } else if (event.testStep instanceof UnskipableStep) {
        initHook((UnskipableStep) event.testStep);
    }
}
 
Example #2
Source File: AllureCucumber4Jvm.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void handleTestStepStarted(final TestStepStarted event) {
    if (event.testStep instanceof PickleStepTestStep) {
        final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep;
        final String stepKeyword = Optional.ofNullable(
                testSources.getKeywordFromSource(currentFeatureFile.get(), pickleStep.getStepLine())
        ).orElse("UNDEFINED");

        final StepResult stepResult = new StepResult()
                .setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText()))
                .setStart(System.currentTimeMillis());

        lifecycle.startStep(getTestCaseUuid(currentTestCase.get()), getStepUuid(pickleStep), stepResult);

        pickleStep.getStepArgument().stream()
                .filter(PickleTable.class::isInstance)
                .findFirst()
                .ifPresent(table -> createDataTableAttachment((PickleTable) table));
    } else if (event.testStep instanceof HookTestStep) {
        initHook((HookTestStep) event.testStep);
    }
}
 
Example #3
Source File: AllureCucumber3Jvm.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private void handleTestStepStarted(final TestStepStarted event) {
    if (event.testStep instanceof PickleStepTestStep) {
        final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep;
        final String stepKeyword = Optional.ofNullable(
                cucumberSourceUtils.getKeywordFromSource(currentFeatureFile, pickleStep.getStepLine())
        ).orElse("UNDEFINED");

        final StepResult stepResult = new StepResult()
                .setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText()))
                .setStart(System.currentTimeMillis());

        lifecycle.startStep(getTestCaseUuid(currentTestCase), getStepUuid(pickleStep), stepResult);

        pickleStep.getStepArgument().stream()
                .filter(PickleTable.class::isInstance)
                .findFirst()
                .ifPresent(table -> createDataTableAttachment((PickleTable) table));
    } else if (event.testStep instanceof HookTestStep) {
        initHook((HookTestStep) event.testStep);
    }
}
 
Example #4
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, testSourceReadHandler);
    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventhandler);
    publisher.registerHandlerFor(WriteEvent.class, writeEventhandler);
    publisher.registerHandlerFor(TestRunFinished.class, runFinishedHandler);
}
 
Example #5
Source File: AllureCucumber2Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #6
Source File: AllureCucumber4Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #7
Source File: AllureCucumber3Jvm.java    From allure-java with Apache License 2.0 5 votes vote down vote up
@Override
public void setEventPublisher(final EventPublisher publisher) {
    publisher.registerHandlerFor(TestSourceRead.class, featureStartedHandler);

    publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);
    publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);

    publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);
    publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);

    publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);
    publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler);
}
 
Example #8
Source File: CucumberReportAdapter.java    From openCypher with Apache License 2.0 5 votes vote down vote up
private Consumer<TCKEvents.StepStarted> stepStartedEvent() {
    return event -> {
        Long startedAt = time();
        stepTimestamp.put(event.correlationId(), startedAt);
        Step step = event.step();
        if (shouldReport(step)) {
            int line = outlineLocation(step.source().getLocations());
            TCKTestStep testStep = new TCKTestStep(step.source(), checkNull(currentTestCase).getUri(), line);
            TestStepStarted cucumberEvent = new TestStepStarted(startedAt, checkNull(currentTestCase), testStep);
            bus.handle(cucumberEvent);
        }
    };
}
 
Example #9
Source File: ExtentCucumberAdapter.java    From extentreports-cucumber4-adapter with Apache License 2.0 4 votes vote down vote up
@Override
public void receive(TestStepStarted event) {
    handleTestStepStarted(event);
}