Skip to content

Commit

Permalink
Merge pull request #2661 from Fork-World/2660-fail_annotation_in_xml_…
Browse files Browse the repository at this point in the history
…report

#2660 fail annotation in xml report
  • Loading branch information
ptrthomas authored Mar 3, 2025
2 parents 41c0454 + 6c18e0c commit f84b6d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static File saveJunitXml(String targetDir, FeatureResult result, String f
testCase.setAttribute("name", name);
testCase.setAttribute("time", formatter.format(sr.getDurationMillis() / 1000));
Element stepsHolder;
if (error != null) {
if (error != null && sr.isFailed()) {
stepsHolder = doc.createElement("failure");
stepsHolder.setAttribute("message", error.getMessage());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,25 @@ void testCustomTags() {
File file = ReportUtils.saveJunitXml("target", fr.result, null);
assertTrue(FileUtils.toString(file).contains(expectedCustomTags));
}

@Test
void testFailAnnotationXML() {
String expectedSystemout = "<system-out>";
Feature feature = Feature.read("classpath:com/intuit/karate/core/fail-tag.feature");
FeatureRuntime fr = FeatureRuntime.of(new Suite(), new FeatureCall(feature));
fr.run();
File file = ReportUtils.saveJunitXml("target", fr.result, null);
assertTrue(FileUtils.toString(file).contains(expectedSystemout));
}

@Test
void testFailAnnotationXMLFailure() {
String expectedSystemout = "<failure";
Feature feature = Feature.read("classpath:com/intuit/karate/core/fail-tag-failure.feature");
FeatureRuntime fr = FeatureRuntime.of(new Suite(), new FeatureCall(feature));
fr.run();
File file = ReportUtils.saveJunitXml("target", fr.result, null);
assertTrue(FileUtils.toString(file).contains(expectedSystemout));
}

}

0 comments on commit f84b6d6

Please sign in to comment.