This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-29601] New functional tests
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 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
61 changes: 61 additions & 0 deletions
61
plugin/src/test/java/hudson/plugins/findbugs/workflow/WorkflowCompatibilityTest.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,61 @@ | ||
package hudson.plugins.findbugs.workflow; | ||
|
||
import java.io.File; | ||
|
||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import hudson.FilePath; | ||
|
||
import hudson.model.Result; | ||
|
||
import hudson.plugins.findbugs.FindBugsPublisher; | ||
|
||
/** | ||
* Test workflow compatibility. | ||
*/ | ||
public class WorkflowCompatibilityTest { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
/** | ||
* Run a workflow job using {@link FindBugsPublisher} and check for success. | ||
*/ | ||
@Test | ||
public void findbugsPublisherWorkflowStep() throws Exception { | ||
j.jenkins.getInjector().injectMembers(this); | ||
WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "wf"); | ||
File wfile = new File(j.jenkins.getRootDir() + "/workspace/wf/target"); | ||
wfile.mkdirs(); | ||
FilePath report = new FilePath(wfile).child("findbugs.xml"); | ||
report.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/hudson/plugins/findbugs/parser/findbugs-native.xml")); | ||
job.setDefinition(new CpsFlowDefinition( | ||
"node {" + | ||
" step([$class: 'FindBugsPublisher'])" + | ||
"}")); | ||
j.assertBuildStatusSuccess(job.scheduleBuild2(0)); | ||
} | ||
|
||
/** | ||
* Run a workflow job using {@link FindBugsPublisher} with a failing threshols of 0, so the given example file | ||
* "/hudson/plugins/findbugs/parser/findbugs-native.xml" will make the build to fail. | ||
*/ | ||
@Test | ||
public void findbugsPublisherWorkflowStepSetLimits() throws Exception { | ||
j.jenkins.getInjector().injectMembers(this); | ||
WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "wf"); | ||
File wfile = new File(j.jenkins.getRootDir() + "/workspace/wf/target"); | ||
wfile.mkdirs(); | ||
FilePath report = new FilePath(wfile).child("findbugsXml.xml"); | ||
report.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/hudson/plugins/findbugs/parser/findbugs-native.xml")); | ||
job.setDefinition(new CpsFlowDefinition( | ||
"node {" + | ||
" step([$class: 'FindBugsPublisher', pattern: '**/findbugsXml.xml', failedTotalAll: '0', usePreviousBuildAsReference: false])" + | ||
"}")); | ||
j.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()); | ||
} | ||
} |