From e727075f3c61016bbe7b2225f87f9d028437729e Mon Sep 17 00:00:00 2001 From: Artem Eroshenko Date: Tue, 17 Oct 2023 20:45:27 +0300 Subject: [PATCH] fix screenshots in steps (via #62) --- .../xcresults/export/Allure2ExportFormatter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java b/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java index 9ad5da1..aa98eda 100644 --- a/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java +++ b/src/main/java/io/eroshenkoam/xcresults/export/Allure2ExportFormatter.java @@ -180,11 +180,12 @@ private void parseStep(final JsonNode activity, return; } - if (activity.has(ATTACHMENTS)) { - context.getCurrent().getAttachments().addAll(getAttachments(activity.get(ATTACHMENTS).get(VALUES))); - } + final Optional> attachments = Optional.ofNullable(activity.get(ATTACHMENTS)) + .map(a -> a.get(VALUES)) + .map(this::getAttachments); if (activityTitle.startsWith("Start Test at") && activity.has(ACTIVITY_START)) { context.getResult().setStart(parseDate(activity.get(ACTIVITY_START).get(VALUE).asText())); + attachments.ifPresent(context.getCurrent().getAttachments()::addAll); return; } @@ -193,6 +194,7 @@ private void parseStep(final JsonNode activity, .setStatus(Status.PASSED) .setSteps(new ArrayList<>()) .setAttachments(new ArrayList<>()); + attachments.ifPresent(step.getAttachments()::addAll); final boolean hasAssertionMessage = activityTitle.startsWith("Assertion Failure") || activityTitle.contains("Test skipped");