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));
}
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));
}
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));
}
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;
}
Aggregations