Skip to content

Commit

Permalink
add history-id support (via #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
eroshenkoam authored Jul 8, 2020
1 parent 77e055b commit 52b14ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static io.eroshenkoam.xcresults.util.ParseUtil.parseDate;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

public class Allure2ExportFormatter implements ExportFormatter {

Expand All @@ -44,6 +42,8 @@ public class Allure2ExportFormatter implements ExportFormatter {
private static final String VALUE = "_value";
private static final String VALUES = "_values";

private static final String SUITE = "suite";

@Override
public TestResult format(final ExportMeta meta, final JsonNode node) {
final TestResult result = new TestResult()
Expand All @@ -55,7 +55,9 @@ public TestResult format(final ExportMeta meta, final JsonNode node) {
result.setName(node.get(NAME).get(VALUE).asText());
}
if (node.has(IDENTIFIER)) {
result.setFullName(node.get(IDENTIFIER).get(VALUE).asText());
final String identifier = node.get(IDENTIFIER).get(VALUE).asText();
result.setHistoryId(getHistoryId(meta, identifier));
result.setFullName(identifier);
}
if (node.has(STATUS)) {
result.setStatus(getTestStatus(node));
Expand Down Expand Up @@ -260,4 +262,9 @@ public StepContext child(final ExecutableItem next) {
}
}

private String getHistoryId(final ExportMeta meta, final String identifier) {
final String suite = meta.getLabels().getOrDefault(SUITE, "Default");
return String.format("%s/%s", suite, identifier);
}

}
20 changes: 2 additions & 18 deletions src/main/java/io/eroshenkoam/xcresults/export/ExportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,10 @@ private void runUnsafe() throws Exception {
}
}

private ExportMeta getTestMeta(ExportMeta meta, JsonNode testableSummary) {
private ExportMeta getTestMeta(final ExportMeta meta, final JsonNode testableSummary) {
final ExportMeta exportMeta = new ExportMeta();
exportMeta.setStart(meta.getStart());
meta.getLabels().forEach((key, value) -> {
exportMeta.label(key, value);
});

meta.getLabels().forEach(exportMeta::label);
exportMeta.label(SUITE, testableSummary.get(TARGET_NAME).get(VALUE).asText());
return exportMeta;
}
Expand Down Expand Up @@ -220,19 +217,6 @@ private List<JsonNode> getTestSummaries(final JsonNode test) {
return summaries;
}

private List<String> getTestSummaryRefs(final JsonNode test) {
final List<String> refs = new ArrayList<>();
if (test.has(SUMMARY_REF)) {
refs.add(test.get(SUMMARY_REF).get(ID).get(VALUE).asText());
}
if (test.has(SUBTESTS)) {
for (final JsonNode subTest : test.get(SUBTESTS).get(VALUES)) {
refs.addAll(getTestSummaryRefs(subTest));
}
}
return refs;
}

private JsonNode readSummary() {
final ProcessBuilder builder = new ProcessBuilder();
builder.command(
Expand Down

0 comments on commit 52b14ff

Please sign in to comment.