-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce suite name and some bugs fixing #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,15 @@ public class ExportCommand implements Runnable { | |
|
||
private static final String SUMMARY_REF = "summaryRef"; | ||
|
||
private static final String SUITE = "suite"; | ||
|
||
private static final String ID = "id"; | ||
private static final String TYPE = "_type"; | ||
private static final String NAME = "_name"; | ||
private static final String VALUE = "_value"; | ||
private static final String VALUES = "_values"; | ||
private static final String DISPLAY_NAME = "displayName"; | ||
private static final String IDENTIFIER = "identifier"; | ||
private static final String TARGET_NAME = "targetName"; | ||
|
||
private static final String TEST_REF = "testsRef"; | ||
|
||
|
@@ -108,19 +110,22 @@ private void runUnsafe() throws Exception { | |
testRefIds.put(action.get(ACTION_RESULT).get(TEST_REF).get(ID).get(VALUE).asText(), meta); | ||
} | ||
} | ||
|
||
final Map<JsonNode, ExportMeta> testSummaries = new HashMap<>(); | ||
testRefIds.forEach((testRefId, meta) -> { | ||
final JsonNode testRef = getReference(testRefId); | ||
for (JsonNode summary : testRef.get(SUMMARIES).get(VALUES)) { | ||
for (JsonNode testableSummary : summary.get(TESTABLE_SUMMARIES).get(VALUES)) { | ||
final ExportMeta testMeta = getTestMeta(meta, testableSummary); | ||
for (JsonNode test : testableSummary.get(TESTS).get(VALUES)) { | ||
getTestSummaries(test).forEach(testSummary -> { | ||
testSummaries.put(testSummary, testRefIds.get(testRefId)); | ||
testSummaries.put(testSummary, testMeta); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
System.out.println(String.format("Export information about %s test summaries...", testSummaries.size())); | ||
final Map<String, String> attachmentsRefs = new HashMap<>(); | ||
testSummaries.forEach((testSummary, meta) -> { | ||
|
@@ -139,6 +144,17 @@ private void runUnsafe() throws Exception { | |
} | ||
} | ||
|
||
private ExportMeta getTestMeta(ExportMeta meta, JsonNode testableSummary) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure suite name is captured and exported as part of JSON so that allure report when generate, the test will be categorised by suite |
||
final ExportMeta exportMeta = new ExportMeta(); | ||
exportMeta.setStart(meta.getStart()); | ||
meta.getLabels().forEach((key, value) -> { | ||
exportMeta.label(key, value); | ||
}); | ||
|
||
exportMeta.label(SUITE, testableSummary.get(TARGET_NAME).get(VALUE).asText()); | ||
return exportMeta; | ||
} | ||
|
||
private void exportTestSummary(final ExportMeta meta, final JsonNode testSummary) { | ||
Path testSummaryPath = null; | ||
Object formattedResult = null; | ||
|
@@ -190,10 +206,12 @@ private List<JsonNode> getTestSummaries(final JsonNode test) { | |
if (test.has(SUMMARY_REF)) { | ||
final String ref = test.get(SUMMARY_REF).get(ID).get(VALUE).asText(); | ||
summaries.add(getReference(ref)); | ||
} else { | ||
if (test.has(TYPE) && test.get(TYPE).get(NAME).textValue().equals("ActionTestMetadata")) { | ||
summaries.add(test); | ||
} | ||
} | ||
if (test.has(TYPE) && test.get(TYPE).get(NAME).textValue().equals("ActionTestMetadata")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the introduction of unit test support has resulted in duplicate tests being exported in JSON. When allure report is generated, the number of tests shown are double. |
||
summaries.add(test); | ||
} | ||
|
||
if (test.has(SUBTESTS)) { | ||
for (final JsonNode subTest : test.get(SUBTESTS).get(VALUES)) { | ||
summaries.addAll(getTestSummaries(subTest)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix test run that take lesser than 1 second will show as 0 second in allure report.