Search in sources :

Example 1 with Attachment

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

the class TestCaseState method attach.

@Override
public void attach(String data, String mediaType, String name) {
    requireNonNull(data);
    requireNonNull(mediaType);
    requireActiveTestStep();
    bus.send(new EmbedEvent(bus.getInstant(), testCase, data.getBytes(UTF_8), mediaType, name));
    Attachment attachment = createAttachment();
    attachment.setBody(data);
    attachment.setContentEncoding(ContentEncoding.IDENTITY);
    attachment.setMediaType(mediaType);
    if (name != null) {
        attachment.setFileName(name);
    }
    bus.send(createEnvelope(attachment));
}
Also used : Attachment(io.cucumber.messages.types.Attachment) EmbedEvent(io.cucumber.plugin.event.EmbedEvent)

Example 2 with Attachment

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

the class TestCaseState method attach.

@Override
public void attach(byte[] data, String mediaType, String name) {
    requireNonNull(data);
    requireNonNull(mediaType);
    requireActiveTestStep();
    bus.send(new EmbedEvent(bus.getInstant(), testCase, data, mediaType, name));
    Attachment attachment = createAttachment();
    attachment.setBody(Base64.getEncoder().encodeToString(data));
    attachment.setContentEncoding(ContentEncoding.BASE_64);
    attachment.setMediaType(mediaType);
    if (name != null) {
        attachment.setFileName(name);
    }
    bus.send(createEnvelope(attachment));
}
Also used : Attachment(io.cucumber.messages.types.Attachment) EmbedEvent(io.cucumber.plugin.event.EmbedEvent)

Example 3 with Attachment

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

the class TestCaseState method log.

@Override
public void log(String text) {
    requireActiveTestStep();
    bus.send(new WriteEvent(bus.getInstant(), testCase, text));
    Attachment attachment = createAttachment();
    attachment.setBody(text);
    attachment.setContentEncoding(ContentEncoding.IDENTITY);
    attachment.setMediaType("text/x.cucumber.log+plain");
    bus.send(createEnvelope(attachment));
}
Also used : WriteEvent(io.cucumber.plugin.event.WriteEvent) Attachment(io.cucumber.messages.types.Attachment)

Example 4 with Attachment

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

the class TestCaseState method createAttachment.

private Attachment createAttachment() {
    Attachment attachment = new Attachment();
    attachment.setTestCaseStartedId(testExecutionId.toString());
    attachment.setTestStepId(currentTestStepId.toString());
    return attachment;
}
Also used : Attachment(io.cucumber.messages.types.Attachment)

Aggregations

Attachment (io.cucumber.messages.types.Attachment)4 EmbedEvent (io.cucumber.plugin.event.EmbedEvent)2 WriteEvent (io.cucumber.plugin.event.WriteEvent)1