Skip to content

Commit

Permalink
Merge pull request #63 from slide/master
Browse files Browse the repository at this point in the history
Fix JENKINS-41134
  • Loading branch information
slide committed Jan 27, 2017
2 parents 90e7ddb + 3b99c65 commit 631c413
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/hudson/tasks/junit/TestResult.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void merge(TestResult other) {
suite.setParent(null); // otherwise freeze ignores it suite.setParent(null); // otherwise freeze ignores it
add(suite); add(suite);
} }
tally();
} }


private boolean strictEq(Object lhs, Object rhs) { private boolean strictEq(Object lhs, Object rhs) {
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/hudson/tasks/junit/TestResultTest.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -150,6 +150,27 @@ public void testDuplicatedTestSuiteIsNotCounted() throws IOException, URISyntaxE
assertEquals("Wrong duration for test result", 1.0, testResult.getDuration(), 0.01); assertEquals("Wrong duration for test result", 1.0, testResult.getDuration(), 0.01);
} }


@Issue("JENKINS-41134")
@Test
public void testMerge() throws IOException, URISyntaxException {
TestResult first = new TestResult();
TestResult second = new TestResult();

first.parse(getDataFile("JENKINS-41134/TestSuite_first.xml"));
second.parse(getDataFile("JENKINS-41134/TestSuite_second.xml"));
assertEquals("Fail count should be 0", 0, first.getFailCount());
first.merge(second);
assertEquals("Fail count should now be 1", 1, first.getFailCount());

first = new TestResult();
second = new TestResult();
first.parse(getDataFile("JENKINS-41134/TestSuite_first.xml"));
second.parse(getDataFile("JENKINS-41134/TestSuite_second_dup_first.xml"));
assertEquals("Fail count should be 0", 0, first.getFailCount());
first.merge(second);
assertEquals("Fail count should now be 1", 1, first.getFailCount());
}

private static final XStream XSTREAM = new XStream2(); private static final XStream XSTREAM = new XStream2();


static { static {
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="TestSuite_first" tests="1" errors="0" failures="0" skip="0" timestamp="2012-04-05T10:50:00">
<testcase classname="TestFoo" name="bar" time="157.980" />
</testsuite>
</testsuites>
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="TestSuite_second" tests="1" errors="0" failures="1" skip="0" timestamp="2012-04-05T10:50:00">
<testcase classname="TestFoo2" name="bar2" time="123.980">
<failure message="PROGRAM.cbl:2 Use a program name that matches the source file name" type="WARNING">
WARNING: Use a program name that matches the source file name
Category: COBOL Code Review – Naming Conventions
File: /project/PROGRAM.cbl
Line: 2
</failure>
</testcase>
</testsuite>
</testsuites>
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="TestSuite_first" tests="1" errors="0" failures="1" skip="0" timestamp="2012-04-05T10:55:00">
<testcase classname="TestFoo" name="bar" time="157.980">
<failure message="PROGRAM.cbl:2 Use a program name that matches the source file name" type="WARNING">
WARNING: Use a program name that matches the source file name
Category: COBOL Code Review – Naming Conventions
File: /project/PROGRAM.cbl
Line: 2
</failure>
</testcase>
</testsuite>
</testsuites>

0 comments on commit 631c413

Please sign in to comment.