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));
}
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));
}
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.");
}
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));
}
}
Aggregations