Search in sources :

Example 6 with MavenModuleSet

use of org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet 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 7 with MavenModuleSet

use of org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method should_detect_regular_expression_in_maven_job.

/**
 * Verifies that the plugin correctly works in maven jobs for tags that are treated as regular expression.
 */
@Test
public void should_detect_regular_expression_in_maven_job() throws Exception {
    MavenModuleSet job = createMavenJob("/tasks_plugin/regexp", settings -> {
        settings.setPattern("**/*.txt");
        settings.setNormalPriorityTags("^.*(TODO(?:[0-9]*))(.*)$");
        settings.setAsRegexp(true);
    });
    verifyRegularExpressionScannerResult(job);
}
Also used : MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Test(org.junit.Test)

Example 8 with MavenModuleSet

use of org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet in project acceptance-test-harness by jenkinsci.

the class TaskScannerPluginTest method should_find_tasks_in_maven_project.

/**
 * Verifies several task scanner functions for a maven project such as - treatment of exclusion pattern - correct
 * counting of warnings - correct prioritisation of warnings - changing build status based on thresholds.
 */
@Test
public void should_find_tasks_in_maven_project() throws Exception {
    MavenModuleSet job = createMavenJob("/tasks_plugin/sample_tasks_project", "clean package test", settings -> {
        settings.setPattern("**/*.java");
        settings.setExcludePattern("**/*Test.java");
        settings.setHighPriorityTags("FIXME");
        settings.setNormalPriorityTags("TODO");
        settings.setLowPriorityTags("@Deprecated");
        settings.setIgnoreCase(false);
    });
    // as one of the unit tests fail, the build should be unstable
    Build build = buildUnstableJob(job);
    assertThatTasksResultExists(job, build);
    build.open();
    TaskScannerAction action = new TaskScannerAction(build);
    // The expected task priorities are:
    // - 1x high
    // - 1x medium
    // - 1x low
    assertThatOpenTaskCountLinkIs(action, 3, 1);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(3));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
    // re-configure the job and set a threshold to mark the build as failed
    editJob(false, job, TasksMavenSettings.class, settings -> {
        settings.setBuildFailedTotalHigh("0");
        settings.setBuildFailedTotalNormal("5");
        settings.setBuildFailedTotalLow("10");
    });
    // as the threshold for high priority warnings is exceeded, the build should be marked as failed
    build = buildFailingJob(job);
    assertThatTasksResultExists(job, build);
    build.open();
    // check build result text
    assertThat(action.getPluginResult(build), is("Plug-in Result: FAILED - 1 warning of priority High exceeds the threshold of 0 by 1 (Reference build: #1)"));
    action.open();
    // no change in warning counts expected
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) TaskScannerAction(org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction) MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Test(org.junit.Test)

Example 9 with MavenModuleSet

use of org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet in project acceptance-test-harness by jenkinsci.

the class FindBugsPluginTest method should_retrieve_results_from_maven_job.

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

Example 10 with MavenModuleSet

use of org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet in project acceptance-test-harness by jenkinsci.

the class FindBugsPluginTest method should_set_result_to_failed_if_warning_found.

/**
 * Builds a maven project and checks if it failed.
 */
@Test
public void should_set_result_to_failed_if_warning_found() {
    MavenModuleSet job = createMavenJob(settings -> settings.setBuildFailedTotalAll("0"));
    buildJobAndWait(job).shouldFail();
}
Also used : MavenModuleSet(org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet) Test(org.junit.Test)

Aggregations

MavenModuleSet (org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet)22 Test (org.junit.Test)21 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)9 Build (org.jenkinsci.test.acceptance.po.Build)7 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)5 Issue (org.jvnet.hudson.test.Issue)5 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)4 CheckStyleAction (org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction)2 MavenBuild (org.jenkinsci.test.acceptance.plugins.maven.MavenBuild)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ArtifactoryContainer (org.jenkinsci.test.acceptance.docker.fixtures.ArtifactoryContainer)1 MailhogContainer (org.jenkinsci.test.acceptance.docker.fixtures.MailhogContainer)1 ArtifactoryPublisher (org.jenkinsci.test.acceptance.plugins.artifactory.ArtifactoryPublisher)1 FindBugsAction (org.jenkinsci.test.acceptance.plugins.findbugs.FindBugsAction)1 JobConfigHistory (org.jenkinsci.test.acceptance.plugins.job_config_history.JobConfigHistory)1 Change (org.jenkinsci.test.acceptance.plugins.job_config_history.JobConfigHistory.Change)1 Mailer (org.jenkinsci.test.acceptance.plugins.mailer.Mailer)1 MavenModule (org.jenkinsci.test.acceptance.plugins.maven.MavenModule)1 MavenModuleBuild (org.jenkinsci.test.acceptance.plugins.maven.MavenModuleBuild)1 MavenProjectConfig (org.jenkinsci.test.acceptance.plugins.maven.MavenProjectConfig)1