Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-47194] xUnit should not consider report generated by other x…
…Unit step XUnit build step or publisher use an instance of processor than generates output report to a shared common folder. This cause on latest step thresholds consider also reports produced by previous steps. Processor now generate an identifier that permits to generate reports into an unique output folder.
- Loading branch information
Showing
9 changed files
with
225 additions
and
194 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
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
102 changes: 102 additions & 0 deletions
102
src/test/java/org/jenkinsci/plugins/xunit/XUnitPublisherTest.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,102 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2016, Andrew Bayer, CloudBees Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
package org.jenkinsci.plugins.xunit; | ||
|
||
import java.io.IOException; | ||
|
||
import org.jenkinsci.lib.dtkit.type.TestType; | ||
import org.jenkinsci.plugins.xunit.threshold.FailedThreshold; | ||
import org.jenkinsci.plugins.xunit.threshold.XUnitThreshold; | ||
import org.jenkinsci.plugins.xunit.types.GoogleTestType; | ||
import org.junit.Assert; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.recipes.LocalData; | ||
|
||
import hudson.FilePath; | ||
import hudson.Launcher; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Result; | ||
import hudson.model.Run; | ||
import hudson.model.TaskListener; | ||
import hudson.tasks.BuildStepDescriptor; | ||
import hudson.tasks.Publisher; | ||
|
||
public class XUnitPublisherTest { | ||
|
||
@SuppressWarnings("serial") | ||
public static class SpyXUnitPublisher extends XUnitPublisher { | ||
|
||
public SpyXUnitPublisher(TestType[] tools, XUnitThreshold[] thresholds, int thresholdMode, String testTimeMargin) { | ||
super(tools, thresholds, thresholdMode, testTimeMargin); | ||
} | ||
|
||
@Override | ||
public void perform(Run<?, ?> build, | ||
FilePath workspace, | ||
Launcher launcher, | ||
TaskListener listener) throws InterruptedException, IOException { | ||
super.perform(build, workspace, launcher, listener); | ||
Assert.assertEquals("Unexpected build FAILURE setup by the first publisher", build.getResult(), Result.SUCCESS); | ||
} | ||
|
||
@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
@Override | ||
public BuildStepDescriptor getDescriptor() { | ||
return new BuildStepDescriptor<Publisher>(SpyXUnitPublisher.class) { | ||
|
||
@Override | ||
public boolean isApplicable(Class<? extends AbstractProject> jobType) { | ||
return true; | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Rule | ||
public JenkinsRule jenkinsRule = new JenkinsRule(); | ||
|
||
@LocalData | ||
@Issue("JENKINS-47194") | ||
@Test | ||
public void different_build_steps_use_separate_output_folders() throws Exception { | ||
// FreeStyleProject job = getBaseJob("JENKINS-47194"); | ||
FreeStyleProject job = jenkinsRule.jenkins.createProject(FreeStyleProject.class, "JENKINS-47194"); | ||
|
||
TestType[] tools = new TestType[] { new GoogleTestType("input.xml", false, false, false, true) }; | ||
|
||
XUnitThreshold threshold1 = new FailedThreshold(); | ||
threshold1.setFailureThreshold("2"); | ||
job.getPublishersList().add(new SpyXUnitPublisher(tools, new XUnitThreshold[] { threshold1 }, 1, "3000")); | ||
|
||
XUnitThreshold threshold2 = new FailedThreshold(); | ||
threshold2.setFailureThreshold("0"); | ||
job.getPublishersList().add(new XUnitPublisher(tools, new XUnitThreshold[] { threshold2 }, 1, "3000")); | ||
|
||
jenkinsRule.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()); | ||
} | ||
} |
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
27 changes: 0 additions & 27 deletions
27
src/test/java/org/jenkinsci/plugins/xunit/service/TempWorkspace.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.