Search in sources :

Example 11 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method assertThatConfigurationTabIsCorrectlyFilled.

private void assertThatConfigurationTabIsCorrectlyFilled(final MatrixProject job) {
    SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
    expectedConfigurationDetails.put("user_axis=one", 4);
    expectedConfigurationDetails.put("user_axis=two", 6);
    expectedConfigurationDetails.put("user_axis=three", 2);
    WarningsAction action = createJavaProjectAction(job);
    assertThat(action.getModulesTabContents(), is(expectedConfigurationDetails));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)

Example 12 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_detect_errors_in_console_log.

/**
 * Checks whether the warnings plugin finds one Maven warning in the console log. The result should be a build with
 * 1 Maven Warning.
 */
@Test
public void should_detect_errors_in_console_log() {
    FreeStyleJob job = createNoFilesFreeStyleJob(settings -> settings.addConsoleParser("Maven"));
    job.configure();
    job.addShellStep("mvn clean install || true");
    job.save();
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "Maven Warnings");
    WarningsAction action = new WarningsAction(build, "Maven", "Maven");
    assertThatWarningsCountInSummaryIs(action, 1);
    assertThatNewWarningsCountInSummaryIs(action, 1);
    action.open();
    assertThat(action.getNumberOfNewWarnings(), is(1));
    assertThat(action.getNumberOfWarnings(), is(1));
    assertThat(action.getNumberOfFixedWarnings(), is(0));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(1));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) Test(org.junit.Test)

Example 13 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_have_correct_details.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_have_correct_details() throws ExecutionException, InterruptedException {
    WarningsAction action = createAndBuildCompileJobOnAgent(resource("/warnings_plugin/WarningMain.java"), "javac -Xlint:all WarningMain.java");
    SortedMap<String, String> details = action.getDetailsTabContents();
    assertThat("Assert the proper detail count.", details.entrySet(), hasSize(3));
    assertThatDetailsAre(details, "redundant cast to TextClass", "WarningMain.java:10");
    // removing tested entry from details.
    details.remove(details.firstKey());
    assertThatDetailsAre(details, "redundant cast to TextClass", "WarningMain.java:11");
    // removing tested entry from details.
    details.remove(details.firstKey());
    assertThatDetailsAre(details, "division by zero", "WarningMain.java:14");
}
Also used : WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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 14 with WarningsAction

use of org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_include_warnings_specified_in_included_parts.

/**
 * Checks whether the warnings plugin picks only specific warnings. The warnings to include are given by two include
 * patterns {".*include.*", ".*default.*"}. The result should be a build with 5 Java Warnings (from a file that
 * contains 9 warnings).
 */
@Test
public void should_include_warnings_specified_in_included_parts() {
    FreeStyleJob job = createFreeStyleJob(WARNINGS_FILE_FOR_INCLUDE_EXCLUDE_TESTS, settings -> {
        settings.addWorkspaceScanner(JAVA_TITLE, "**/*");
        settings.setIncludePattern(".*/include*/.*, .*/default/.*");
    });
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    assertThatWarningsCountInSummaryIs(action, 5);
    assertThatNewWarningsCountInSummaryIs(action, 5);
    action.open();
    assertThat(action.getNumberOfWarnings(), is(5));
    assertThat(action.getNumberOfNewWarnings(), is(5));
    assertThat(action.getNumberOfFixedWarnings(), is(0));
    assertThat(action.getNumberOfWarningsWithHighPriority(), is(0));
    assertThat(action.getNumberOfWarningsWithNormalPriority(), is(5));
    assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) Test(org.junit.Test)

Aggregations

WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)14 Test (org.junit.Test)10 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)9 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 Build (org.jenkinsci.test.acceptance.po.Build)8 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)5 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)3 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)3 Issue (org.jvnet.hudson.test.Issue)3 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)2 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)2 ShellBuildStep (org.jenkinsci.test.acceptance.po.ShellBuildStep)2 Ignore (org.junit.Ignore)1 WebElement (org.openqa.selenium.WebElement)1