Search in sources :

Example 6 with Envelope

use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.

the class TestStep method emitTestStepFinished.

private void emitTestStepFinished(TestCase testCase, EventBus bus, UUID textExecutionId, Instant stopTime, Duration duration, Result result) {
    bus.send(new TestStepFinished(stopTime, testCase, this, result));
    TestStepResult testStepResult = new TestStepResult();
    if (result.getError() != null) {
        testStepResult.setMessage(extractStackTrace(result.getError()));
    }
    testStepResult.setStatus(from(result.getStatus()));
    testStepResult.setDuration(javaDurationToDuration(duration));
    Envelope envelope = new Envelope();
    envelope.setTestStepFinished(new io.cucumber.messages.types.TestStepFinished(textExecutionId.toString(), id.toString(), testStepResult, javaInstantToTimestamp(stopTime)));
    bus.send(envelope);
}
Also used : TestStepResult(io.cucumber.messages.types.TestStepResult) TestStepFinished(io.cucumber.plugin.event.TestStepFinished) Envelope(io.cucumber.messages.types.Envelope)

Example 7 with Envelope

use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.

the class CachingGlue method emitStepDefined.

private void emitStepDefined(CoreStepDefinition coreStepDefinition) {
    bus.send(new StepDefinedEvent(bus.getInstant(), new io.cucumber.plugin.event.StepDefinition(coreStepDefinition.getStepDefinition().getLocation(), coreStepDefinition.getExpression().getSource())));
    io.cucumber.messages.types.StepDefinition messagesStepDefinition = new io.cucumber.messages.types.StepDefinition();
    messagesStepDefinition.setId(coreStepDefinition.getId().toString());
    messagesStepDefinition.setPattern(new StepDefinitionPattern(coreStepDefinition.getExpression().getSource(), getExpressionType(coreStepDefinition)));
    coreStepDefinition.getDefinitionLocation().ifPresent(reference -> messagesStepDefinition.setSourceReference(createSourceReference(reference)));
    Envelope envelope = new Envelope();
    envelope.setStepDefinition(messagesStepDefinition);
    bus.send(envelope);
}
Also used : StepDefinitionPattern(io.cucumber.messages.types.StepDefinitionPattern) StepDefinedEvent(io.cucumber.plugin.event.StepDefinedEvent) StepDefinition(io.cucumber.core.backend.StepDefinition) Envelope(io.cucumber.messages.types.Envelope)

Example 8 with Envelope

use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.

the class CachingGlue method emitParameterTypeDefined.

private void emitParameterTypeDefined(ParameterType<?> parameterType) {
    io.cucumber.messages.types.ParameterType messagesParameterType = new io.cucumber.messages.types.ParameterType();
    messagesParameterType.setId(bus.generateId().toString());
    messagesParameterType.setName(parameterType.getName());
    messagesParameterType.setRegularExpressions(parameterType.getRegexps());
    messagesParameterType.setPreferForRegularExpressionMatch(parameterType.preferForRegexpMatch());
    messagesParameterType.setUseForSnippets(parameterType.useForSnippets());
    Envelope envelope = new Envelope();
    envelope.setParameterType(messagesParameterType);
    bus.send(envelope);
}
Also used : ParameterType(io.cucumber.cucumberexpressions.ParameterType) Envelope(io.cucumber.messages.types.Envelope)

Example 9 with Envelope

use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.

the class TestSourcesModel method parseGherkinSource.

private void parseGherkinSource(URI path) {
    if (!pathToReadEventMap.containsKey(path)) {
        return;
    }
    String source = pathToReadEventMap.get(path).getSource();
    List<Envelope> sources = singletonList(makeSourceEnvelope(source, path.toString()));
    List<Envelope> envelopes = Gherkin.fromSources(sources, true, true, true, () -> String.valueOf(UUID.randomUUID())).collect(toList());
    GherkinDocument gherkinDocument = envelopes.stream().map(Envelope::getGherkinDocument).filter(Objects::nonNull).findFirst().orElse(null);
    pathToAstMap.put(path, gherkinDocument);
    Map<Long, AstNode> nodeMap = new HashMap<>();
    AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
    for (FeatureChild child : gherkinDocument.getFeature().getChildren()) {
        processFeatureDefinition(nodeMap, child, currentParent);
    }
    pathToNodeMap.put(path, nodeMap);
}
Also used : HashMap(java.util.HashMap) Objects(java.util.Objects) FeatureChild(io.cucumber.messages.types.FeatureChild) GherkinDocument(io.cucumber.messages.types.GherkinDocument) Envelope(io.cucumber.messages.types.Envelope) Gherkin.makeSourceEnvelope(io.cucumber.gherkin.Gherkin.makeSourceEnvelope)

Example 10 with Envelope

use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.

the class TestCaseState method createEnvelope.

private Envelope createEnvelope(Attachment attachment) {
    Envelope envelope = new Envelope();
    envelope.setAttachment(attachment);
    return envelope;
}
Also used : Envelope(io.cucumber.messages.types.Envelope)

Aggregations

Envelope (io.cucumber.messages.types.Envelope)22 UUID (java.util.UUID)8 Test (org.junit.jupiter.api.Test)8 EventBus (io.cucumber.core.eventbus.EventBus)5 Feature (io.cucumber.core.gherkin.Feature)5 ArrayList (java.util.ArrayList)5 TimeServiceEventBus (io.cucumber.core.runtime.TimeServiceEventBus)4 StepDefinition (io.cucumber.core.backend.StepDefinition)3 TestRunFinished (io.cucumber.messages.types.TestRunFinished)3 TestRunStarted (io.cucumber.messages.types.TestRunStarted)3 Timestamp (io.cucumber.messages.types.Timestamp)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 URI (java.net.URI)3 List (java.util.List)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 HookDefinition (io.cucumber.core.backend.HookDefinition)2 ScenarioScoped (io.cucumber.core.backend.ScenarioScoped)2 TestCaseState (io.cucumber.core.backend.TestCaseState)2 TestFeatureParser (io.cucumber.core.feature.TestFeatureParser)2 EmbedEvent (io.cucumber.plugin.event.EmbedEvent)2