use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method verifyRegularExpressionScannerResult.
private void verifyRegularExpressionScannerResult(final Job job) {
Build build = buildSuccessfulJob(job);
build.open();
TaskScannerAction action = new TaskScannerAction(build);
assertThatOpenTaskCountLinkIs(action, 5, 1);
action.open();
assertThat(action.getNumberOfWarnings(), is(5));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
}
use of org.jenkinsci.test.acceptance.po.Build 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));
}
use of org.jenkinsci.test.acceptance.po.Build 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");
}
use of org.jenkinsci.test.acceptance.po.Build 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.po.Build in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method status_thresholds_step3.
/**
* This method does special configurations for test step 3 of test {@link TaskScannerPluginTest#should_set_build_result_based_on_status_thresholds()}.
* The scenario is that the file set consists of 9 files, whereof - 7 files are to be scanned for tasks
* <p/>
* The expected task priorities are: - 0x high - 5x medium - 1x low
* <p/>
* So, the build status shall be UNSTABLE due to normal priority threshold is exceeded by 1.
*
* @param job the {@link FreeStyleJob} created in the Test
* @param action a the {@link TaskScannerAction} object for the current job
* @return The modified {@link org.jenkinsci.test.acceptance.po.FreeStyleJob}.
*/
private FreeStyleJob status_thresholds_step3(final FreeStyleJob job, final TaskScannerAction action) {
editJob(false, job, TasksFreestyleSettings.class, settings -> {
// add tag "XXX"
settings.setNormalPriorityTags("TODO,XXX");
// remove tag "???"
settings.setLowPriorityTags("@Deprecated");
});
Build lastBuild = buildUnstableJob(job);
lastBuild.open();
assertThatOpenTaskCountLinkIs(action, 6, 7);
assertThatNewOpenTaskCountLinkIs(action, 3);
// Note:
// As the previous build was unstable the determination which warnings have changed is
// done based on the reference buil (#1)!!
// The same applies to step 4 to 6
assertThat(action.getResultLinkByXPathText("3 new open tasks"), is("tasksResult/new"));
action.open();
assertThat(action.getNumberOfWarnings(), is(6));
assertThat(action.getNumberOfNewWarnings(), is(3));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: UNSTABLE - 5 warnings of priority Normal exceed the threshold of 4 by 1 (Reference build: #1)"));
return job;
}
Aggregations