use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method status_thresholds_step7.
/**
* This method does special configurations for test step 6 of test {@link TaskScannerPluginTest#should_set_build_result_based_on_status_thresholds()}.
* Another shell step is added which consists of a small script to replace all TODO, todo, FIXME, fixme, XXX,
* Deprecated occurences in the workspace files by the string "CLOSED".
* <p/>
* The scenario is that the file set consists of 19 files, whereof - 17 files are to be scanned for tasks
* <p/>
* The expected task priorities are: - 0x high - 0x medium - 1x low
* <p/>
* So, the build status shall be SUCCESS as no threshold will be exceeded.
*
* @param job the {@link org.jenkinsci.test.acceptance.po.FreeStyleJob} created in the Test
* @param action a the {@link org.jenkinsci.test.acceptance.plugins.tasks.TaskScannerAction} object for the current
* job
* @return The modified {@link org.jenkinsci.test.acceptance.po.FreeStyleJob}.
*/
private FreeStyleJob status_thresholds_step7(final FreeStyleJob job, final TaskScannerAction action) {
job.configure();
job.addShellStep("NEW=\"CLOSED\"\n" + "for t in \"todo\" \"TODO\" \"XXX\" \"fixme\" \"FIXME\" \"Deprecated\"\n" + "do\n" + " OLD=$t\n" + " for f in `ls`\n" + " do\n" + " if [ -f $f -a -r $f ]; then\n" + " if file --mime-type $f | grep -q \"^${f}: text/\"; then\n" + " sed \"s/$OLD/$NEW/\" \"$f\" > \"${f}.new\"\n" + " mv \"${f}.new\" \"$f\"\n" + " else\n" + " echo \"Info: $f is not a text file. Skipped.\"\n" + " fi" + " else\n" + " echo \"Error: Cannot read $f\"\n" + " fi\n" + " done\n" + "done");
job.save();
Build lastBuild = buildSuccessfulJob(job);
lastBuild.open();
assertThatOpenTaskCountLinkIs(action, 1, 17);
assertThatNewOpenTaskCountLinkIs(action, 1);
assertThatClosedTaskCountLinkIs(action, 3);
action.open();
assertThat(action.getNumberOfWarnings(), is(1));
assertThat(action.getNumberOfNewWarnings(), is(1));
assertThat(action.getNumberOfFixedWarnings(), is(3));
assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(1));
assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: SUCCESS - no threshold has been exceeded (Reference build: #1)"));
return job;
}
use of org.jenkinsci.test.acceptance.po.Build 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.po.Build in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method status_thresholds_step2.
/**
* This method does special configurations for test step 2 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 - 4x medium - 2x low
* <p/>
* So, the build status shall be UNSTABLE due to low 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_step2(final FreeStyleJob job, final TaskScannerAction action) {
editJob("/tasks_plugin/fileset1", false, job, TasksFreestyleSettings.class, settings -> {
// add tag "???"
settings.setLowPriorityTags("@Deprecated,\\?\\?\\?");
});
Build lastBuild = buildUnstableJob(job);
lastBuild.open();
assertThatOpenTaskCountLinkIs(action, 6, 7);
assertThatNewOpenTaskCountLinkIs(action, 3);
action.open();
assertThat(action.getNumberOfWarnings(), is(6));
assertThat(action.getNumberOfNewWarnings(), is(3));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(4));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: UNSTABLE - 2 warnings of priority Low exceed the threshold of 1 by 1 (Reference build: #1)"));
return job;
}
use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.
the class TaskScannerPluginTest method status_thresholds_step4.
/**
* This method does special configurations for test step 4 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: - 1x high - 5x medium - 2x low
* <p/>
* So, the build status shall be UNSTABLE due to high 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_step4(final FreeStyleJob job, final TaskScannerAction action) {
editJob(false, job, TasksFreestyleSettings.class, settings -> {
// add tag "???"
settings.setLowPriorityTags("@Deprecated,\\?\\?\\?");
// add tag "FIXME"
settings.setHighPriorityTags("FIXME");
});
Build lastBuild = buildUnstableJob(job);
lastBuild.open();
assertThatOpenTaskCountLinkIs(action, 8, 7);
assertThatNewOpenTaskCountLinkIs(action, 5);
action.open();
assertThat(action.getNumberOfWarnings(), is(8));
assertThat(action.getNumberOfNewWarnings(), is(5));
assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
assertThat(action.getPluginResult(lastBuild), is("Plug-in Result: UNSTABLE - 1 warning of priority High exceeds the threshold of 0 by 1 (Reference build: #1)"));
return job;
}
use of org.jenkinsci.test.acceptance.po.Build in project acceptance-test-harness by jenkinsci.
the class ViolationsPluginTest method freestyle.
@Test
public void freestyle() {
FreeStyleJob job = jenkins.jobs.create();
job.configure();
job.copyDir(resource("/violations_plugin"));
job.addPublisher(Violations.class).config("fxcop").pattern("fxcop/*");
job.save();
Build build = job.startBuild().shouldSucceed();
assertThat(job.action(ViolationsAction.class), hasViolations("fxcop", "2", "2"));
assertThat(build.action(ViolationsAction.class), hasViolations("fxcop", "2", "2"));
}
Aggregations