Search in sources :

Example 71 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_scan_files_on_slave.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_files_on_slave() {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource("/warnings_plugin/out.txt"));
    job.addPublisher(WarningsPublisher.class).addWorkspaceFileScanner(JAVA_ID, "out.txt");
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThatActionExists(job, build, "Java Warnings");
    build.open();
    assertThat(driver, hasContent("Java Warnings: " + 2));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) 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 72 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_parse_codenarc_on_master.

@Test
@WithPlugins("violations")
public void should_parse_codenarc_on_master() {
    FreeStyleJob job = createFreeStyleJob(RESOURCE_CODE_NARC_REPORT_PATH, settings -> settings.addWorkspaceScanner("Codenarc", RESOURCE_CODE_NARC_REPORT));
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "Codenarc Warnings");
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 73 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins 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 74 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_include_jobs_that_have_been_built.

/**
 * This test creates jobs and a list view. The job filter only allows jobs that have been built yet.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_include_jobs_that_have_been_built() {
    List<Job> notBuiltJobs = createAmountOfJobs(2, false);
    List<Job> builtJobs = createAmountOfJobs(3, true);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobFilters {\n" + "    buildTrend {\n" + "      matchType(MatchType.INCLUDE_MATCHED)\n" + "      amountType(AmountType.BUILDS)\n" + "    }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsJob(builtJobs.get(0)));
    assertThat(view, containsJob(builtJobs.get(1)));
    assertThat(view, containsJob(builtJobs.get(2)));
    assertThat(view, not(containsJob(notBuiltJobs.get(0))));
    assertThat(view, not(containsJob(notBuiltJobs.get(1))));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Example 75 with WithPlugins

use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.

the class JobDslPluginTest method job_filters_regex_name_exclude_unmatched.

/**
 * This test creates a listView and 4 jobs. The job filters are checking the name with a regex and
 * jobs not matching the regex are excluded in the listView.
 */
@Test
@WithPlugins("view-job-filters")
public void job_filters_regex_name_exclude_unmatched() {
    Job job1 = createJobWithName(EXAMPLE_DISABLED_NAME);
    Job job2 = createJobWithName(EXAMPLE_ENABLED_NAME);
    List<Job> jobs = createAmountOfJobs(2, false);
    String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + "  columns {\n" + "    name()\n" + "  }\n" + "  jobs{\n" + "    names('" + job1.name + "','" + job2.name + "','" + jobs.get(0).name + "','" + jobs.get(1).name + "')\n" + "  }\n" + "  jobFilters {\n" + "        regex {\n" + "            matchType(MatchType.EXCLUDE_UNMATCHED)\n" + "            matchValue(RegexMatchValue.NAME)\n" + "            regex('" + LIST_VIEW_REGEX + "')\n" + "        }\n" + "  }\n" + "}";
    View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
    assertThat(view, containsJob(job1));
    assertThat(view, containsJob(job2));
    assertThat(view, not(containsJob(jobs.get(0))));
    assertThat(view, not(containsJob(jobs.get(1))));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Job(org.jenkinsci.test.acceptance.po.Job) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) ListView(org.jenkinsci.test.acceptance.po.ListView) View(org.jenkinsci.test.acceptance.po.View) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins)

Aggregations

WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)89 Test (org.junit.Test)89 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)71 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)53 Build (org.jenkinsci.test.acceptance.po.Build)39 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)31 Issue (org.jvnet.hudson.test.Issue)25 Job (org.jenkinsci.test.acceptance.po.Job)19 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)15 WorkflowJob (org.jenkinsci.test.acceptance.po.WorkflowJob)15 ListView (org.jenkinsci.test.acceptance.po.ListView)13 View (org.jenkinsci.test.acceptance.po.View)13 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)12 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)11 JobDslBuildStep (org.jenkinsci.test.acceptance.plugins.job_dsl.JobDslBuildStep)10 Matchers.containsString (org.hamcrest.Matchers.containsString)9 GlobalSecurityConfig (org.jenkinsci.test.acceptance.po.GlobalSecurityConfig)9 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)8 Ignore (org.junit.Ignore)8 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)5