Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FIXED JENKINS-12205] : recent versions of MatrixProject no longer in…
…clude the test results of their child jobs. Iterate over them manually.
- Loading branch information
Willem Verstraeten
committed
Sep 15, 2015
1 parent
09948c5
commit dabdd8e
Showing
3 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/test/java/hudson/plugins/view/dashboard/test/TestSummaryForMatrixJobs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package hudson.plugins.view.dashboard.test; | ||
|
||
import hudson.Launcher; | ||
import hudson.matrix.MatrixBuild; | ||
import hudson.matrix.MatrixProject; | ||
import hudson.matrix.TextAxis; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.BuildListener; | ||
import hudson.model.Result; | ||
import hudson.model.TopLevelItem; | ||
import hudson.tasks.junit.JUnitResultArchiver; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.TestBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class TestSummaryForMatrixJobs { | ||
@Rule | ||
public JenkinsRule jenkins = new JenkinsRule(); | ||
|
||
private MatrixProject matrixProject; | ||
|
||
@Before | ||
public void createMatrixJob() throws IOException { | ||
matrixProject = jenkins.createMatrixProject("top"); | ||
matrixProject.getAxes().add(new TextAxis("param", "one", "two")); | ||
matrixProject.getBuildersList().add(new TestBuilder() { | ||
@Override | ||
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { | ||
build.getWorkspace().child("testresult.xml").copyFrom(TestSummaryForMatrixJobs.class.getResource("/hudson/plugins/view/dashboard/test_failure.xml")); | ||
return true; | ||
} | ||
}); | ||
matrixProject.getPublishersList().add(new JUnitResultArchiver("testresult.xml", true, null)); | ||
} | ||
|
||
@Test | ||
public void summaryIncludesMatrixJobs() throws Exception { | ||
MatrixBuild result = matrixProject.scheduleBuild2(0).get(); | ||
jenkins.assertBuildStatus(Result.UNSTABLE, result); | ||
|
||
TestResultSummary testSummary = TestUtil.getTestResultSummary(Collections.singleton((TopLevelItem) matrixProject)); | ||
assertThat(testSummary.getFailed(), is((2))); | ||
assertThat(testSummary.getSuccess(), is((2))); | ||
} | ||
|
||
@After | ||
public void cleanupMatrixJob() throws IOException, InterruptedException { | ||
matrixProject.delete(); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/test/resources/hudson/plugins/view/dashboard/test_failure.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<testsuite errors="0" failures="1" hostname="anniesue" name="com.luciad.format.aixmcommon.view.lightspeed.TLspAIXMStylerAcceptanceTest" skipped="0" tests="2" time="12.829" timestamp="2015-09-14T14:37:11"> | ||
<properties/> | ||
<testcase classname="test" name="failure" time="0.376"> | ||
<failure message="description" type="junit.framework.AssertionFailedError"> | ||
detail message | ||
</failure> | ||
</testcase> | ||
<testcase classname="test.case" name="success" time="0.893" /> | ||
<system-out><![CDATA[System out | ||
]]></system-out> | ||
<system-err><![CDATA[System err | ||
]]></system-err> | ||
</testsuite> |