Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[JENKINS-29601] New functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amuniz committed Jul 27, 2015
1 parent 50e358c commit c45e9c0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugin/pom.xml
Expand Up @@ -68,6 +68,24 @@
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
Expand Down
@@ -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());
}
}

0 comments on commit c45e9c0

Please sign in to comment.