Search in sources :

Example 6 with FreeStyleJob

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)));
}
Also used : WarningsPerProjectPortlet(org.jenkinsci.test.acceptance.plugins.analysis_collector.WarningsPerProjectPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 7 with FreeStyleJob

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));
}
Also used : AnalysisCollectorAction(org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorAction) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 8 with FreeStyleJob

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));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) AnalysisCollectorAction(org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorAction) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 9 with FreeStyleJob

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;
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob)

Example 10 with FreeStyleJob

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>")));
}
Also used : ListView(org.jenkinsci.test.acceptance.po.ListView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AnalysisCollectorColumn(org.jenkinsci.test.acceptance.plugins.analysis_collector.AnalysisCollectorColumn) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Aggregations

FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)263 Test (org.junit.Test)242 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)170 Build (org.jenkinsci.test.acceptance.po.Build)105 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)51 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)37 Issue (org.jvnet.hudson.test.Issue)32 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)23 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)23 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)21 Resource (org.jenkinsci.test.acceptance.junit.Resource)19 DashboardView (org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)19 File (java.io.File)17 DockerContainer (org.jenkinsci.test.acceptance.docker.DockerContainer)17 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)17 PublishGlobalPublisher (org.jenkinsci.test.acceptance.plugins.publish_over.PublishGlobalPublisher)17 SvnContainer (org.jenkinsci.test.acceptance.docker.fixtures.SvnContainer)16 SubversionScm (org.jenkinsci.test.acceptance.plugins.subversion.SubversionScm)13 ListView (org.jenkinsci.test.acceptance.po.ListView)12 Pattern (java.util.regex.Pattern)11