use of org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction 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);
}
use of org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction 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"));
}
use of org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method should_run_on_failed_builds_if_configured.
/**
* Check the "Run always" option of the publisher, i.e whether the task scanner activity is skipped in case the main
* build step has already failed and the option "run always" is not activated. The option is activated for the
* second part to also scan for tasks in this failed job
*/
@Test
public void should_run_on_failed_builds_if_configured() throws Exception {
FreeStyleJob job = createFreeStyleJob(settings -> {
settings.setPattern("**/*.java");
settings.setExcludePattern("**/*Test.java");
settings.setHighPriorityTags("FIXME");
settings.setIgnoreCase(true);
settings.setCanRunOnFailed(false);
});
job.configure();
// ensures the FAILURE status of the main build
job.addShellStep("exit 1");
job.save();
Build build = buildFailingJob(job);
// the task scanner activity shall be skipped due to the failed main build
// so we have to search for the particular console output
assertThatConsoleContains(build, ".*\\[TASKS\\] Skipping publisher since build result is FAILURE");
// now activate "Run always"
editJob(false, job, TasksFreestyleSettings.class, settings -> settings.setCanRunOnFailed(true));
build = buildFailingJob(job);
build.open();
TaskScannerAction action = new TaskScannerAction(build);
// as the failed result is now ignored, we expect 2 open tasks, both
// of high priority and both considered as new warnings.
assertThatOpenTaskCountLinkIs(action, 2, 7);
assertThatNewOpenTaskCountLinkIs(action, 2);
action.open();
assertThat(action.getNumberOfWarnings(), is(2));
assertThat(action.getNumberOfWarningsWithHighPriority(), is(2));
}
Aggregations