Search in sources :

Example 31 with FreeStyleJob

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

the class TaskScannerPluginTest method should_set_build_result_based_on_status_thresholds.

/**
 * Verifies the correct treatment of the status thresholds (totals). Therefore a more complex test case has been
 * created which modifies files and task tags to scan for multiple times to create appropriate scenarios for
 * different thresholds.
 * <p/>
 * It shall also check whether the determination / justification of the build status is done based on the highest
 * priority threshold that has been exceeded.
 * <p/>
 * The test case consists of 6 steps: 1 - create reference build (SUCCESS) -> no threshold exceeded 2 - exceed the
 * UNSTABLE LOW threshold 3 - exceed the UNSTABLE NORMAL threshold but do not exceed UNSTABLE LOW 4 - exceed
 * UNSTABLE LOW, NORMAL and HIGH -> build status justified with HIGH priority tasks 5 - further exceed the UNSTABLE
 * TOTAL threshold -> new justification for build status 6 - further exceed the FAILURE TOTAL threshold -> build
 * failed 7 - remove most of the task tags -> build is stable again
 */
@Test
public void should_set_build_result_based_on_status_thresholds() {
    FreeStyleJob job = createFreeStyleJob("/tasks_plugin/fileset1_less", settings -> {
        settings.setPattern("**/*.java");
        settings.setExcludePattern("**/*Test.java");
        // no high prio tags
        settings.setHighPriorityTags("");
        settings.setNormalPriorityTags("TODO");
        settings.setLowPriorityTags("@Deprecated");
        settings.setIgnoreCase(false);
        // setup thresholds
        settings.setBuildUnstableTotalLow("1");
        settings.setBuildUnstableTotalNormal("4");
        settings.setBuildUnstableTotalHigh("0");
        settings.setBuildUnstableTotalAll("10");
        settings.setBuildFailedTotalAll("15");
    });
    TaskScannerAction action = new TaskScannerAction(job.getLastBuild());
    // In order to increase readability each step has been placed in a separate
    // private function
    job = status_thresholds_step1(job, action);
    job = status_thresholds_step2(job, action);
    job = status_thresholds_step3(job, action);
    job = status_thresholds_step4(job, action);
    job = status_thresholds_step5(job, action);
    job = status_thresholds_step6(job, action);
    status_thresholds_step7(job, action);
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TaskScannerAction(org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction) Test(org.junit.Test)

Example 32 with FreeStyleJob

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

the class TaskScannerPluginTest method should_use_file_encoding_windows1251_when_parsing_files.

/**
 * Check the correct treatment and display of tasks in files with windows-1251 (a.k.a. cp1251) encoding. Reproduces
 * the observations described in JENKINS-22744.
 */
// Note: In order to run this test in IntelliJ the encoding of the source needs to be set to windows-1251
@Test
@Issue("JENKINS-22744")
public void should_use_file_encoding_windows1251_when_parsing_files() throws Exception {
    FreeStyleJob job = createFreeStyleJob("/tasks_plugin/cp1251_files", settings -> {
        settings.setPattern("**/*.java");
        settings.setExcludePattern("**/*Test.java");
        settings.setHighPriorityTags("FIXME");
        settings.setNormalPriorityTags("TODO");
        settings.setIgnoreCase(true);
        settings.setDefaultEncoding("windows-1251");
    });
    Build build = buildSuccessfulJob(job);
    assertThatTasksResultExists(job, build);
    build.open();
    TaskScannerAction action = new TaskScannerAction(build);
    assertThatOpenTaskCountLinkIs(action, 2, 1);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(2));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(1));
    assertWarningExtraction(action, "TestTaskScanner.java", 5, "TODO", "пример комментария на русском");
    verifySourceLine(action, "TestTaskScanner.java", 4, "4   //FIXME тестирование Jenkins", "High Priority");
    verifySourceLine(action, "TestTaskScanner.java", 5, "5   //TODO пример комментария на русском", "Normal Priority");
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TaskScannerAction(org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 33 with FreeStyleJob

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

the class TaskScannerPluginTest method should_find_multiple_task_tags.

/**
 * Verifies that the plugin correctly works for multiple tags per priority. In the first step the task scanner is
 * configured with two tags for high priority tasks. Prior to the second build also the normal and low priority tag
 * list is extended.
 */
@Test
public void should_find_multiple_task_tags() throws Exception {
    FreeStyleJob job = createFreeStyleJob(settings -> {
        settings.setPattern("**/*.java");
        settings.setExcludePattern("**/*Test.java");
        settings.setHighPriorityTags("FIXME,BUG");
        settings.setNormalPriorityTags("TODO");
        settings.setLowPriorityTags("@Deprecated");
        settings.setIgnoreCase(true);
    });
    Build build = buildSuccessfulJob(job);
    build.open();
    TaskScannerAction action = new TaskScannerAction(build);
    // The file set consists of 9 files, whereof
    // - 2 file names match the exclusion pattern
    // - 7 files are to be scanned for tasks
    // - 6 files actually contain tasks with the specified tags
    // 
    // The expected task priorities are:
    // - 3x high
    // - 4x medium
    // - 1x low
    assertThatOpenTaskCountLinkIs(action, 8, 7);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(8));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(3));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(4));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
    // now add further task tags. Then the publisher shall also
    // find the second priority task in TSRDockerImage.java (line 102) amd
    // a low priority task in TSRDockerImage.java (line 56).
    editJob(false, job, TasksFreestyleSettings.class, settings -> {
        settings.setNormalPriorityTags("TODO,XXX");
        settings.setLowPriorityTags("@Deprecated,\\?\\?\\?");
    });
    build = buildSuccessfulJob(job);
    build.open();
    action = new TaskScannerAction(build);
    assertThatOpenTaskCountLinkIs(action, 10, 7);
    assertThatNewOpenTaskCountLinkIs(action, 2);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(10));
    assertThat(action.getNumberOfNewWarnings(), is(2));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(3));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
    assertFilesTabFS1E2(action);
    assertTypesTabFS1E2(action);
    assertWarningsTabFS1E2(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)

Example 34 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob 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 35 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob 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

FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)263 Test (org.junit.Test)242 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)170 Build (org.jenkinsci.test.acceptance.po.Build)105 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)51 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)37 Issue (org.jvnet.hudson.test.Issue)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)23 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)23 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)21 Resource (org.jenkinsci.test.acceptance.junit.Resource)19 DashboardView (org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)19 File (java.io.File)17 DockerContainer (org.jenkinsci.test.acceptance.docker.DockerContainer)17 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)17 PublishGlobalPublisher (org.jenkinsci.test.acceptance.plugins.publish_over.PublishGlobalPublisher)17 SvnContainer (org.jenkinsci.test.acceptance.docker.fixtures.SvnContainer)16 SubversionScm (org.jenkinsci.test.acceptance.plugins.subversion.SubversionScm)13 ListView (org.jenkinsci.test.acceptance.po.ListView)12 Pattern (java.util.regex.Pattern)11