Search in sources :

Example 11 with Build

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

the class PmdPluginTest method should_find_no_warnings.

/**
 * Configures a job with PMD and checks that the parsed PMD file does not contain warnings.
 */
@Test
public void should_find_no_warnings() {
    FreeStyleJob job = createFreeStyleJob(settings -> settings.pattern.set(PATTERN_WITHOUT_WARNINGS));
    Build lastBuild = buildSuccessfulJob(job);
    assertThatBuildHasNoWarnings(lastBuild);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 12 with Build

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

the class PmdPluginTest method should_retrieve_results_from_maven_job.

/**
 * Builds a maven project and checks if new warnings are displayed.
 */
@Test
public void should_retrieve_results_from_maven_job() {
    MavenModuleSet job = createMavenJob();
    Build build = buildSuccessfulJob(job);
    assertThatPmdResultExists(job, build);
    build.open();
    PmdAction action = new PmdAction(build);
    action.open();
    assertThat(action.getNumberOfNewWarnings(), is(2));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) PmdAction(org.jenkinsci.test.acceptance.plugins.pmd.PmdAction) MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Test(org.junit.Test)

Example 13 with Build

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

the class PmdPluginTest method should_report_new_and_fixed_warnings_in_consecutive_builds.

/**
 * Runs job two times to check if new and fixed warnings are displayed. Afterwards, the first build
 * is deleted and Jenkins is restarted. Then the results of the second build are validated again: the detail
 * pages should then show the same results (see JENKINS-24940).
 */
@Test
@Issue("24940")
public void should_report_new_and_fixed_warnings_in_consecutive_builds() {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    FreeStyleJob job = createFreeStyleJob();
    Build firstBuild = buildJobAndWait(job);
    editJob(PLUGIN_ROOT + "forSecondRun/pmd-warnings.xml", false, job, PmdFreestyleSettings.class);
    Build lastBuild = buildSuccessfulJob(job);
    assertThatPmdResultExists(job, lastBuild);
    lastBuild.open();
    verifyWarningCounts(lastBuild);
    firstBuild.delete();
    jenkins.restart();
    lastBuild.open();
    verifyWarningCounts(lastBuild);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 14 with Build

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

the class PostBuildScriptPluginTest method skip_for_jobs_that_failed.

@Test
public void skip_for_jobs_that_failed() {
    j.configure();
    j.addShellStep("exit 1");
    addMarkerPostBuildStep().runWhenSucceeded();
    j.save();
    Build build = j.startBuild().shouldFail();
    assertThat(build, not(runPostBuildStep()));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 15 with Build

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

the class TaskScannerPluginTest method should_report_closed_tasks.

/**
 * Verifies the detection of closed tasks. Therefore two runs of the same job with the same task scanner setup are
 * conducted but the fileset in the workspace will be replaced by the same files containing less warnings for the
 * second run. The tasks that have been removed shall be correctly listed as closed tasks.
 */
@Test
public void should_report_closed_tasks() throws Exception {
    FreeStyleJob job = createFreeStyleJob(settings -> {
        settings.setPattern("**/*.java");
        settings.setExcludePattern("**/*Test.java");
        settings.setHighPriorityTags("FIXME");
        settings.setNormalPriorityTags("TODO");
        settings.setLowPriorityTags("@Deprecated");
        settings.setIgnoreCase(false);
    });
    buildSuccessfulJob(job);
    // this time we do not check the task scanner output as the result is the same
    // as for single_task_tags_and_exclusion_pattern
    // So we proceed directly with the preparation of build #2
    editJob("/tasks_plugin/fileset1_less", false, job, TasksFreestyleSettings.class);
    Build build = buildSuccessfulJob(job);
    build.open();
    TaskScannerAction action = new TaskScannerAction(build);
    // In the first build the task priorities were
    // - 1x high
    // - 4x medium
    // - 1x low
    // 
    // For the second build (reduced warnings) the expected priorities are
    // - 3x medium
    // 
    // --> we expect 3 closed tasks (1x high, 1x normal, 1x low)
    assertThatOpenTaskCountLinkIs(action, 3, 7);
    assertThatClosedTaskCountLinkIs(action, 3);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(3));
    assertThat(action.getNumberOfFixedWarnings(), is(3));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(3));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
    assertFixedTab(action);
}
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)

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