Search in sources :

Example 1 with PmdAction

use of org.jenkinsci.test.acceptance.plugins.pmd.PmdAction 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 2 with PmdAction

use of org.jenkinsci.test.acceptance.plugins.pmd.PmdAction in project acceptance-test-harness by jenkinsci.

the class PmdPluginTest method verifyWarningCounts.

private void verifyWarningCounts(final Build build) {
    PmdAction action = new PmdAction(build);
    assertThatWarningsCountInSummaryIs(action, 8);
    assertThatNewWarningsCountInSummaryIs(action, 1);
    assertThatFixedWarningsCountInSummaryIs(action, 2);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(8));
    assertThat(action.getNumberOfNewWarnings(), is(1));
    assertThat(action.getNumberOfFixedWarnings(), is(2));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(2));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(6));
    action.openNew();
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
    action.openFixed();
    assertThat(action.getNumberOfRowsInFixedWarningsTable(), is(2));
}
Also used : PmdAction(org.jenkinsci.test.acceptance.plugins.pmd.PmdAction)

Example 3 with PmdAction

use of org.jenkinsci.test.acceptance.plugins.pmd.PmdAction in project acceptance-test-harness by jenkinsci.

the class PmdPluginTest method should_link_to_source_code_in_real_project.

/**
 * Builds a freestyle project and checks if new warning are displayed.
 */
@Test
public void should_link_to_source_code_in_real_project() {
    FreeStyleJob job = createJob(jenkins, PLUGIN_ROOT + "sample_pmd_project", FreeStyleJob.class, PmdFreestyleSettings.class, settings -> settings.pattern.set("target/pmd.xml"));
    setMavenGoal(job, "clean package pmd:pmd");
    Build build = buildSuccessfulJob(job);
    assertThatPmdResultExists(job, build);
    build.open();
    PmdAction action = new PmdAction(build);
    action.open();
    assertThat(action.getNumberOfNewWarnings(), is(2));
    SortedMap<String, Integer> expectedContent = new TreeMap<>();
    expectedContent.put("Main.java:9", TOTAL_NUMBER_OF_WARNINGS);
    expectedContent.put("Main.java:13", 13);
    verifySourceLine(action, "Main.java", 13, "13         if(false) {", "Do not use if statements that are always true or always false.");
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) PmdAction(org.jenkinsci.test.acceptance.plugins.pmd.PmdAction) IsEmptyString(org.hamcrest.text.IsEmptyString) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 4 with PmdAction

use of org.jenkinsci.test.acceptance.plugins.pmd.PmdAction in project acceptance-test-harness by jenkinsci.

the class PmdPluginTest method runBuild.

private void runBuild(final FreeStyleJob job, final int number, final Result expectedResult, final int expectedNewWarnings, final boolean usePreviousAsReference) {
    final String fileName = "pmd-warnings-build" + number + ".xml";
    editJob(PLUGIN_ROOT + fileName, false, job, PmdFreestyleSettings.class, settings -> {
        settings.setNewWarningsThresholdUnstable("0", usePreviousAsReference);
        settings.pattern.set(fileName);
    });
    Build build = buildJobAndWait(job).shouldBe(expectedResult);
    if (expectedNewWarnings > 0) {
        assertThatPmdResultExists(job, build);
        build.open();
        PmdAction action = new PmdAction(build);
        action.open();
        assertThat(action.getNumberOfNewWarnings(), is(expectedNewWarnings));
    }
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) IsEmptyString(org.hamcrest.text.IsEmptyString) PmdAction(org.jenkinsci.test.acceptance.plugins.pmd.PmdAction)

Aggregations

PmdAction (org.jenkinsci.test.acceptance.plugins.pmd.PmdAction)4 Build (org.jenkinsci.test.acceptance.po.Build)3 IsEmptyString (org.hamcrest.text.IsEmptyString)2 Test (org.junit.Test)2 TreeMap (java.util.TreeMap)1 MavenModuleSet (org.jenkinsci.test.acceptance.plugins.maven.MavenModuleSet)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1