Search in sources :

Example 21 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method status_thresholds_step7.

/**
 * This method does special configurations for test step 6 of test {@link TaskScannerPluginTest#should_set_build_result_based_on_status_thresholds()}.
 * Another shell step is added which consists of a small script to replace all TODO, todo, FIXME, fixme, XXX,
 * Deprecated occurences in the workspace files by the string "CLOSED".
 * <p/>
 * The scenario is that the file set consists of 19 files, whereof - 17 files are to be scanned for tasks
 * <p/>
 * The expected task priorities are: -  0x high -  0x medium -  1x low
 * <p/>
 * So, the build status shall be SUCCESS as no threshold will be exceeded.
 *
 * @param job    the {@link org.jenkinsci.test.acceptance.po.FreeStyleJob} created in the Test
 * @param action a the {@link org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction} object for the current
 *               job
 * @return The modified {@link org.jenkinsci.test.acceptance.po.FreeStyleJob}.
 */
private FreeStyleJob status_thresholds_step7(final FreeStyleJob job, final TaskScannerAction action) {
    job.configure();
    job.addShellStep("NEW=\"CLOSED\"\n" + "for t in \"todo\" \"TODO\" \"XXX\" \"fixme\" \"FIXME\" \"Deprecated\"\n" + "do\n" + "  OLD=$t\n" + "  for f in `ls`\n" + "  do\n" + "    if [ -f $f -a -r $f ]; then\n" + "      if file --mime-type $f | grep -q \"^${f}: text/\"; then\n" + "        sed \"s/$OLD/$NEW/\" \"$f\" > \"${f}.new\"\n" + "        mv \"${f}.new\" \"$f\"\n" + "      else\n" + "        echo \"Info: $f is not a text file. Skipped.\"\n" + "      fi" + "    else\n" + "      echo \"Error: Cannot read $f\"\n" + "    fi\n" + "  done\n" + "done");
    job.save();
    Build lastBuild = buildSuccessfulJob(job);
    lastBuild.open();
    assertThatOpenTaskCountLinkIs(action, 1, 17);
    assertThatNewOpenTaskCountLinkIs(action, 1);
    assertThatClosedTaskCountLinkIs(action, 3);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(1));
    assertThat(action.getNumberOfNewWarnings(), is(1));
    assertThat(action.getNumberOfFixedWarnings(), is(3));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
    assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: SUCCESS - no threshold has been exceeded (Reference build: #1)"));
    return job;
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build)

Example 22 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method shouldFindMoreWarningsWhenIgnoringCase.

/**
 * Verifies that different number of open tasks are found depending on the configured case sensitivity option.
 */
@Test
public void shouldFindMoreWarningsWhenIgnoringCase() {
    FreeStyleJob job = createFreeStyleJob();
    buildSuccessfulJob(job);
    // now disable case sensitivity and build again. Then the publisher shall also
    // find the high priority task in Ec2Provider.java:133.
    editJob(false, job, TasksFreestyleSettings.class, settings -> settings.setIgnoreCase(true));
    Build build = buildSuccessfulJob(job);
    build.open();
    TaskScannerAction action = new TaskScannerAction(build);
    assertThatOpenTaskCountLinkIs(action, 7, 7);
    assertThatNewOpenTaskCountLinkIs(action, 1);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(7));
    assertThat(action.getNumberOfNewWarnings(), is(1));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(2));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(4));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
    action.openNew();
    assertThat(action.getResultLinkByXPathText("TSREc2Provider.java:133"), startsWith("source"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TaskScannerAction(org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction) Test(org.junit.Test)

Example 23 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method status_thresholds_step2.

/**
 * This method does special configurations for test step 2 of test {@link TaskScannerPluginTest#should_set_build_result_based_on_status_thresholds()}.
 * The scenario is that the file set consists of 9 files, whereof - 7 files are to be scanned for tasks
 * <p/>
 * The expected task priorities are: - 0x high - 4x medium - 2x low
 * <p/>
 * So, the build status shall be UNSTABLE due to low priority threshold is exceeded by 1.
 *
 * @param job    the {@link FreeStyleJob} created in the Test
 * @param action a the {@link TaskScannerAction} object for the current job
 * @return The modified {@link org.jenkinsci.test.acceptance.po.FreeStyleJob}.
 */
private FreeStyleJob status_thresholds_step2(final FreeStyleJob job, final TaskScannerAction action) {
    editJob("/tasks_plugin/fileset1", false, job, TasksFreestyleSettings.class, settings -> {
        // add tag "???"
        settings.setLowPriorityTags("@Deprecated,\\?\\?\\?");
    });
    Build lastBuild = buildUnstableJob(job);
    lastBuild.open();
    assertThatOpenTaskCountLinkIs(action, 6, 7);
    assertThatNewOpenTaskCountLinkIs(action, 3);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(6));
    assertThat(action.getNumberOfNewWarnings(), is(3));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(4));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
    assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: UNSTABLE - 2 warnings of priority Low exceed the threshold of 1 by 1 (Reference build: #1)"));
    return job;
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build)

Example 24 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method status_thresholds_step4.

/**
 * This method does special configurations for test step 4 of test {@link TaskScannerPluginTest#should_set_build_result_based_on_status_thresholds()}.
 * The scenario is that the file set consists of 9 files, whereof - 7 files are to be scanned for tasks
 * <p/>
 * The expected task priorities are: - 1x high - 5x medium - 2x low
 * <p/>
 * So, the build status shall be UNSTABLE due to high priority threshold is exceeded by 1.
 *
 * @param job    the {@link FreeStyleJob} created in the Test
 * @param action a the {@link TaskScannerAction} object for the current job
 * @return The modified {@link org.jenkinsci.test.acceptance.po.FreeStyleJob}.
 */
private FreeStyleJob status_thresholds_step4(final FreeStyleJob job, final TaskScannerAction action) {
    editJob(false, job, TasksFreestyleSettings.class, settings -> {
        // add tag "???"
        settings.setLowPriorityTags("@Deprecated,\\?\\?\\?");
        // add tag "FIXME"
        settings.setHighPriorityTags("FIXME");
    });
    Build lastBuild = buildUnstableJob(job);
    lastBuild.open();
    assertThatOpenTaskCountLinkIs(action, 8, 7);
    assertThatNewOpenTaskCountLinkIs(action, 5);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(8));
    assertThat(action.getNumberOfNewWarnings(), is(5));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
    assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: UNSTABLE - 1 warning of priority High exceeds the threshold of 0 by 1 (Reference build: #1)"));
    return job;
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build)

Example 25 with Build

use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.

the class ViolationsPluginTest method freestyle.

@Test
public void freestyle() {
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.copyDir(resource("/violations_plugin"));
    job.addPublisher(Violations.class).config("fxcop").pattern("fxcop/*");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThat(job.action(ViolationsAction.class), hasViolations("fxcop", "2", "2"));
    assertThat(build.action(ViolationsAction.class), hasViolations("fxcop", "2", "2"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) MavenModuleBuild(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleBuild) ViolationsAction(org.jenkinsci.test.acceptance.plugins.violations.ViolationsAction) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

Build (org.jenkinsci.test.acceptance.po.Build)175 Test (org.junit.Test)157 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)113 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)101 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)40 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)22 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)20 Issue (org.jvnet.hudson.test.Issue)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)13 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)13 Pattern (java.util.regex.Pattern)11 Job (org.jenkinsci.test.acceptance.po.Job)11 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)9 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)9 GitScm (org.jenkinsci.test.acceptance.plugins.git.GitScm)9 Matchers.containsString (org.hamcrest.Matchers.containsString)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)8 MavenModuleSet (org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet)7 IOException (java.io.IOException)6