Search in sources :

Example 1 with Issue

use of org.jvnet.hudson.test.Issue in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method should_send_mail_with_expanded_tokens.

/**
 * Checks that the plug-in sends a mail after a build has been failed. The content of the mail contains several
 * tokens that should be expanded in the mail with the correct values.
 */
// TODO: we should have two builds so that the numbers are different
@Test
@Issue("JENKINS-25501")
@WithPlugins("email-ext")
public void should_send_mail_with_expanded_tokens() {
    // avoid JENKINS-49026
    checkExtensionAreDeployed("hudson.plugins.analysis.tokens.AbstractTokenMacro", Collections.EMPTY_SET);
    setUpMailer();
    FreeStyleJob job = createFreeStyleJob();
    P projectAction = createProjectAction(job);
    job.editPublisher(projectAction.getFreeStyleSettings(), settings -> settings.setBuildFailedTotalAll("0"));
    String name = projectAction.getUrl().toUpperCase();
    String title = "Analysis-Result";
    configureEmailNotification(job, String.format("%s: ${%s_RESULT}", title, name), String.format("%s: ${%s_COUNT}-${%s_FIXED}-${%s_NEW}", title, name, name, name));
    buildFailingJob(job);
    verifyReceivedMail(String.format("%s: FAILURE", title), String.format("%s: %d-0-%d", title, getNumberOfWarnings(), getNumberOfWarnings()));
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 2 with Issue

use of org.jvnet.hudson.test.Issue in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method should_show_warning_totals_in_view_column_with_link_to_results.

/**
 * 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.
 */
@Test
@Issue("JENKINS-24436")
public void should_show_warning_totals_in_view_column_with_link_to_results() {
    FreeStyleJob job = createFreeStyleJob();
    buildJobAndWait(job).shouldSucceed();
    P projectAction = createProjectAction(job);
    addListViewColumn(projectAction.getViewColumn(), jenkins);
    verifyColumn(projectAction);
}
Also used : FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with Issue

use of org.jvnet.hudson.test.Issue in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method should_show_build_health.

/**
 * Builds a freestyle job with an enabled publisher of the plug-in under test. Sets the thresholds for the trend
 * report so that a health of 0-19% is evaluated for the plug-in under test (shown as tool tip in the Jenkins
 * main view).
 * TODO: Add different health percentages
 */
@Test
@Issue("JENKINS-28360")
public void should_show_build_health() {
    FreeStyleJob job = createFreeStyleJob();
    AnalysisAction projectAction = createProjectAction(job);
    job.editPublisher(projectAction.getFreeStyleSettings(), settings -> {
        settings.setBuildHealthyThreshold(0);
        settings.setBuildUnhealthyThreshold(getNumberOfWarnings());
    });
    buildSuccessfulJob(job);
    jenkins.open();
    List<WebElement> healthElements = all(by.xpath("//div[@class='healthReportDetails']//tr"));
    assertThat(healthElements.size(), is(3));
    String expectedText = String.format("%s: %d %s%s found.", projectAction.getPluginName(), getNumberOfWarnings(), projectAction.getAnnotationName(), plural(getNumberOfWarnings()));
    assertThatHealthReportIs(healthElements.get(1), expectedText, "00to19");
    assertThatHealthReportIs(healthElements.get(2), "Build stability: No recent builds failed.", "80plus");
}
Also used : AnalysisAction(org.jenkinsci.test.acceptance.plugins.analysis_core.AnalysisAction) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebElement(org.openqa.selenium.WebElement) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with Issue

use of org.jvnet.hudson.test.Issue in project acceptance-test-harness by jenkinsci.

the class CheckStylePluginTest method should_show_warnings_per_user.

/**
 * Verifies that blaming of warnings works on agents: creates a new project in a Git repository in a docker
 * container. Registers the same docker container as slave agent to build the project. Uses the recorded build
 * results in checkstyle-result.xml (no actual maven goal is invoked). Verifies that the blame information is
 * correctly assigned for each of the warnings. Also checks, that the age is increased for yet another build.
 */
@Test
@WithPlugins({ "git", "dashboard-view", "analysis-core@1.88-SNAPSHOT", "ssh-slaves" })
@WithDocker
@Issue("JENKINS-6748")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_show_warnings_per_user() {
    // avoid JENKINS-49026
    jenkins.restart();
    DumbSlave agent = createDockerAgent();
    String gitRepositoryUrl = createGitRepositoryInDockerContainer();
    FreeStyleJob job = createFreeStyleJob(jenkins, null, settings -> settings.pattern.set("**/checkstyle-result.xml"));
    job.configure(() -> {
        job.useScm(GitScm.class).url(gitRepositoryUrl).credentials(CREDENTIALS_ID);
        job.setLabelExpression(agent.getName());
    });
    buildSuccessfulJob(job);
    CheckStyleAction action = new CheckStyleAction(job);
    action.open();
    SortedMap<String, Integer> expectedPeople = new TreeMap<>();
    expectedPeople.put("Unknown authors", 1);
    expectedPeople.put("Jenkins-ATH <jenkins-ath@example.org>", 11);
    assertThat(action.getPeopleTabContents(), is(expectedPeople));
    action.find(By.partialLinkText("Jenkins-ATH")).click();
    assertThat(driver, hasContent("Checkstyle Warnings - Jenkins-ATH"));
    action.open();
    SortedMap<String, String> expectedOrigin = new TreeMap<>();
    expectedOrigin.put("Main.java:0", "-");
    expectedOrigin.put("Main.java:2", "Jenkins-ATH");
    expectedOrigin.put("Main.java:4", "Jenkins-ATH");
    expectedOrigin.put("Main.java:6", "Jenkins-ATH");
    expectedOrigin.put("Main.java:9", "Jenkins-ATH");
    expectedOrigin.put("Main.java:13", "Jenkins-ATH");
    expectedOrigin.put("Main.java:18", "Jenkins-ATH");
    expectedOrigin.put("Main.java:23", "Jenkins-ATH");
    expectedOrigin.put("Main.java:24", "Jenkins-ATH");
    expectedOrigin.put("Main.java:27", "Jenkins-ATH");
    assertThat(action.getOriginTabContentsAsStrings(AUTHOR), is(expectedOrigin));
    assertThatAgeIsAt(action, expectedOrigin, 1);
    buildSuccessfulJob(job);
    assertThatAgeIsAt(action, expectedOrigin, 2);
    GraphConfigurationView view = action.configureTrendGraphForUser();
    view.open();
    view.setUserGraph();
    view.save();
    WebElement graph = find(getUsersTrendGraphXpath());
    assertThat(graph.isDisplayed(), is(true));
    verifyNoAuthors(action, true);
    WebElement nothing = getElement(getUsersTrendGraphXpath());
    assertThat(nothing, nullValue());
    verifyNoAuthors(action, false);
}
Also used : CheckStyleAction(org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction) GraphConfigurationView(org.jenkinsci.test.acceptance.plugins.analysis_core.GraphConfigurationView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) TreeMap(java.util.TreeMap) WebElement(org.openqa.selenium.WebElement) Issue(org.jvnet.hudson.test.Issue) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 5 with Issue

use of org.jvnet.hudson.test.Issue in project acceptance-test-harness by jenkinsci.

the class CheckStylePluginTest method should_report_new_and_fixed_warnings_in_consecutive_builds.

/**
 * Runs job two times to check if new and fixed warnings are displayed. Afterwards, the first build
 * is deleted and Jenkins is restarted. Then the results of the second build are validated again: the detail
 * pages should then show the same results (see JENKINS-24940).
 */
@Test
@Issue("24940")
public void should_report_new_and_fixed_warnings_in_consecutive_builds() {
    assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
    FreeStyleJob job = createFreeStyleJob();
    Build firstBuild = buildJobAndWait(job);
    replaceResource(FILE_FOR_2ND_RUN, job);
    Build lastBuild = buildSuccessfulJob(job);
    assertThatCheckStyleResultExists(job, lastBuild);
    lastBuild.open();
    verifyWarningCounts(lastBuild);
    firstBuild.delete();
    jenkins.restart();
    lastBuild.open();
    verifyWarningCounts(lastBuild);
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

Issue (org.jvnet.hudson.test.Issue)233 Test (org.junit.Test)232 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)91 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)69 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)66 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)32 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)30 Map (java.util.Map)27 FreeStyleProject (hudson.model.FreeStyleProject)25 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)25 Build (org.jenkinsci.test.acceptance.po.Build)17 File (java.io.File)14 URL (java.net.URL)13 Ignore (org.junit.Ignore)13 Statement (org.junit.runners.model.Statement)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 Run (hudson.model.Run)10 List (java.util.List)9 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)9 StringParameterDefinition (hudson.model.StringParameterDefinition)8