use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method should_aggregate_warnings_in_dashboard_portlet.
/**
* Sets up a dashboard view with a warnings-per-project portlet. Builds a job and checks if the portlet shows the
* correct number of warnings. Then one of the tools is deselected. The portlet should then show only the remaining
* number of warnings.
*/
@Test
@WithPlugins("dashboard-view")
public void should_aggregate_warnings_in_dashboard_portlet() {
// avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);
FreeStyleJob job = createFreeStyleJob();
buildSuccessfulJob(job);
DashboardView dashboard = jenkins.views.create(DashboardView.class, createRandomName());
dashboard.configure();
dashboard.matchAllJobs();
WarningsPerProjectPortlet portlet = addWarningsPortlet(dashboard);
dashboard.save();
dashboard.open();
verifyWarningsCountInPortlet(job.name, dashboard);
// uncheck Open Tasks
dashboard.configure(() -> portlet.checkCollectedPlugin(TASKS, false));
dashboard.open();
assertThat(dashboard, not(hasWarnings(job.name, TASKS.getId(), TASKS_ALL)));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method should_collect_warnings_of_selected_tools_only.
/**
* Verifies that the plugin only collects warnings of the checked plugins. The test starts with a build that
* collects the warnings of all available tools. Then subsequently a new build is started with one tool removed
* until no tool is checked anymore.
*/
@Test
public void should_collect_warnings_of_selected_tools_only() {
FreeStyleJob job = createFreeStyleJob();
int remaining = TOTAL;
AnalysisCollectorAction action = deselectPluginAndBuild(CHECKSTYLE, job);
remaining -= CHECKSTYLE_ALL;
assertThat(action.getNumberOfWarnings(), is(remaining));
action = deselectPluginAndBuild(FINDBUGS, job);
remaining -= FINDBUGS_ALL;
assertThat(action.getNumberOfWarnings(), is(remaining));
action = deselectPluginAndBuild(PMD, job);
remaining -= PMD_ALL;
assertThat(action.getNumberOfWarnings(), is(remaining));
action = deselectPluginAndBuild(TASKS, job);
remaining -= TASKS_ALL;
assertThat(action.getNumberOfWarnings(), is(remaining));
action = deselectPluginAndBuild(WARNINGS, job);
assertThat(action.getNumberOfWarnings(), is(0));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method should_compute_all_new_open_tasks.
/**
* Verifies that the plugin correctly identifies new open tasks. The first build contains 4 open tasks. The second
* builds adds another 4 open tasks, summing up to a total of 8 open tasks. The second build should then contain 4
* new warnings.
*/
@Test
public void should_compute_all_new_open_tasks() {
FreeStyleJob job = createJob(ANALYSIS_COLLECTOR_PLUGIN_RESOURCES + "/Tasks.java", true);
buildSuccessfulJob(job);
job.configure();
job.copyResource(ANALYSIS_COLLECTOR_PLUGIN_RESOURCES + "/Tasks2.java");
job.save();
Build build = buildSuccessfulJob(job);
AnalysisCollectorAction action = new AnalysisCollectorAction(build);
action.open();
assertThat(action.getNumberOfWarnings(), is(8));
assertThat(action.getNumberOfWarningsWithHighPriority(), is(2));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(4));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(2));
assertThat(action.getNumberOfNewWarnings(), is(4));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method createJob.
private FreeStyleJob createJob(final String resourceToCopy, final boolean addAnalysisPublisher, final Container owner) {
FreeStyleJob job = owner.getJobs().create();
job.configure();
job.copyResource(resourceToCopy);
job.addPublisher(CheckStyleFreestyleSettings.class);
job.addPublisher(PmdFreestyleSettings.class);
job.addPublisher(FindBugsFreestyleSettings.class);
addAndConfigureTasksPublisher(job);
addAndConfigureWarningsPublisher(job);
if (addAnalysisPublisher) {
job.addPublisher(AnalysisCollectorSettings.class);
}
job.save();
return job;
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method should_set_warnings_count_in_list_view_column.
/**
* Sets up a list view with a warnings column. Builds a job and checks if the column shows the correct number of
* warnings and provides a direct link to the actual warning results. Also verifies that the mouse-over tooltip will
* show the correct number of warnings per checked plugin.
*/
@Test
public void should_set_warnings_count_in_list_view_column() {
FreeStyleJob job = createFreeStyleJob();
buildSuccessfulJob(job);
ListView view = jenkins.views.create(ListView.class, "list");
view.configure();
view.matchAllJobs();
view.addColumn(AnalysisCollectorColumn.class);
view.save();
view.open();
WebElement warningsCell = view.find(by.xpath(XPATH_LISTVIEW_WARNING_TD));
assertThat(warningsCell.getText(), is(String.valueOf(TOTAL)));
String tooltip = warningsCell.getAttribute("tooltip");
assertThat(tooltip, allOf(containsString("<a href=\"view/list/job/" + job.name + "/checkstyle\">" + CHECKSTYLE_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/findbugs\">" + FINDBUGS_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/pmd\">" + PMD_ALL + "</a>"), containsString("<a href=\"view/list/job/" + job.name + "/warnings\">" + WARNINGS_ALL + "</a>")));
view.configure();
AnalysisCollectorColumn column = view.getColumn(AnalysisCollectorColumn.class);
column.checkPlugin(PMD, false);
view.save();
view.open();
// check that PMD warnings are not collected to total warning number and tooltip
warningsCell = view.find(by.xpath(XPATH_LISTVIEW_WARNING_TD));
assertThat(warningsCell.getText(), is(String.valueOf(TOTAL - PMD_ALL)));
tooltip = warningsCell.getAttribute("tooltip");
assertThat(tooltip, not(containsString("<a href=\"job/" + job.name + "/pmd\">" + PMD_ALL + "</a>")));
}
Aggregations