Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void attachment(final JoinPoint joinPoint, final Object result) {
);

final byte[] bytes = (result instanceof byte[])
? (byte[]) result : result.toString().getBytes(StandardCharsets.UTF_8);
? (byte[]) result : Objects.toString(result).getBytes(StandardCharsets.UTF_8);
getLifecycle().addAttachment(title, attachment.type(), "", bytes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ public void shouldSetupAttachmentTitleFromMethodSignature() {

}

@Test
public void shouldProcessNullAttachment() throws Exception {
final String uuid = UUID.randomUUID().toString();
final TestResult result = new TestResult().withUuid(uuid);

lifecycle.scheduleTestCase(result);
lifecycle.startTestCase(uuid);

attachmentWithNullValue();

lifecycle.stopTestCase(uuid);
lifecycle.writeTestCase(uuid);

assertThat(results.getTestResults())
.flatExtracting(TestResult::getAttachments)
.extracting("name", "type")
.containsExactly(tuple("attachmentWithNullValue", null));
}

@Attachment
public byte[] attachmentWithNullValue() {
return null;
}

@Attachment
public byte[] attachmentWithoutTitle() {
return new byte[]{};
Expand Down