Skip to content
Permalink
Browse files

[JENKINS-46206] Added a test case.

  • Loading branch information
uhafner committed Aug 18, 2017
1 parent 5baca37 commit 476d11979b09fae7da97410460f2c76803d58c53
Showing with 38 additions and 0 deletions.
  1. +15 −0 src/test/java/plugins/AbstractAnalysisTest.java
  2. +23 −0 src/test/java/plugins/FindBugsPluginTest.java
@@ -582,6 +582,21 @@ private FreeStyleJob createFreeStyleJob() {
* @return the created pipeline
*/
protected WorkflowJob createPipelineWith(final String fileName, final String stepName) {
return createPipelineWith(fileName, stepName, StringUtils.EMPTY);
}

/**
* Creates a pipeline that enables the specified {@code stepName}. The first step of the pipeline copies the
* specified resource {@code fileName} as first instruction to the pipeline.
*
* @param fileName the name of the resource that will be copied to the pipeline (this file will be scanned for
* warnings)
* @param stepName the name of the publisher to run (as a pipeline step)
* @param additionalParameters additional parameters for the step (need to start with a comma)
* @return the created pipeline
*/
protected WorkflowJob createPipelineWith(final String fileName, final String stepName,
final String additionalParameters) {
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
String script = "node {\n"
+ job.copyResourceStep(fileName)
@@ -25,6 +25,7 @@

import java.util.SortedMap;
import java.util.TreeMap;
import java.util.function.Consumer;

import org.jenkinsci.test.acceptance.junit.SmokeTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
@@ -174,6 +175,28 @@ public void should_set_result_to_unstable_if_warning_found() {
buildJobAndWait(job).shouldBeUnstable();
}

/**
* Builds a pipeline project and checks if it is unstable.
*/
@Test

This comment has been minimized.

Copy link
@jglick

jglick Nov 20, 2017

Member

Does this not need to specify @WithPlugins?

This comment has been minimized.

Copy link
@uhafner

uhafner Nov 20, 2017

Author Member

Yes, thanks! I'll always run the tests with PLUGIN_DIR so these kind of bugs are hard to spot.

public void should_set_pipeline_result() {
verifyResult("unstable", Build::shouldBeUnstable);
verifyResult("failed", Build::shouldFail);
}

private void verifyResult(final String result, final Consumer<Build> buildResultCheck) {
String[] parameters = {", " + result + "TotalAll: '5'",
", " + result + "TotalHigh: '1'",
", " + result + "TotalNormal: '3'"};

for (String additionalParameters : parameters) {
WorkflowJob job = createPipelineWith(FILE_WITH_6_WARNINGS, "FindBugsPublisher",
additionalParameters);
Build build = buildJobAndWait(job);
buildResultCheck.accept(build);
}
}

/**
* Builds a maven project and checks if it failed.
*/

0 comments on commit 476d119

Please sign in to comment.
You can’t perform that action at this time.