Skip to content

Commit

Permalink
Parsing error tag in JUnit reports tomasbjerre#115
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Nov 15, 2020
1 parent f3e0e6f commit 8853ccd
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public Set<Violation> parseReportOutput(
if (xmlr.getLocalName().equalsIgnoreCase("testcase")) {
className = getAttribute(xmlr, "classname");
name = getAttribute(xmlr, "name");
} else if (xmlr.getLocalName().equalsIgnoreCase("failure")) {
} else if (xmlr.getLocalName().equalsIgnoreCase("failure")
|| xmlr.getLocalName().equalsIgnoreCase("error")) {
final Violation v = this.parseFailure(xmlr, className, name, violationsLogger);
if (v != null) {
violations.add(v);
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/se/bjurr/violations/lib/JUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,25 @@ public void testThatViolationsCanBeParsedFromJunit113() {
.startsWith("shouldDrawIBIntoEmptyWorld : java.lang.AssertionError");
assertThat(violation0.getSeverity()).isEqualTo(ERROR);
}

@Test
public void testThatViolationsCanBeParsedFromJENKINS64117() {
final String rootFolder = getRootFolder();

final Set<Violation> actual =
violationsApi() //
.withPattern(".*/junit/JENKINS-64117\\.xml$") //
.inFolder(rootFolder) //
.findAll(JUNIT) //
.violations();

assertThat(actual) //
.hasSize(1);

final Violation violation0 = new ArrayList<>(actual).get(0);
assertThat(violation0.getFile())
.isEqualTo("eu/pinteam/kyoto/gunit/testenv/test/CalculationUtilTest.java");
assertThat(violation0.getMessage()).startsWith("runCalculationScriptTest : The container");
assertThat(violation0.getSeverity()).isEqualTo(ERROR);
}
}
203 changes: 203 additions & 0 deletions src/test/resources/junit/JENKINS-64117.xml

Large diffs are not rendered by default.

0 comments on commit 8853ccd

Please sign in to comment.