use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method job_filters_status_failed_include_matched.
/**
* This test creates a job and runs a build which fails. Afterwards 4 new jobs get created as well as a listView.
* The job filter of the listView is set to show jobs which build status is 'FAILED'.
*/
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_include_matched() {
Job failedJob = createJobThatFails();
List<Job> jobs = createAmountOfJobs(4, true);
String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + " columns {\n" + " name()\n" + " }\n" + " jobFilters {\n" + " status {\n" + " matchType(MatchType.INCLUDE_MATCHED)\n" + " status(Status.FAILED)\n" + " }\n" + " }\n" + "}";
View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
assertThat(view, containsJob(failedJob));
assertThat(view, not(containsJob(jobs.get(0))));
assertThat(view, not(containsJob(jobs.get(1))));
assertThat(view, not(containsJob(jobs.get(2))));
assertThat(view, not(containsJob(jobs.get(3))));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_create_build_with_given_name.
/**
* Tests whether a build display name is registered to a build of a job created by JobDsl
* when a build name is set to this job and the seed job and this job are build.
*/
@Test
@WithPlugins("build-name-setter")
public void should_create_build_with_given_name() {
// Arrange
String jobName = "MyJob";
String buildName = "MyBuild";
String jobDslScript = String.format("job('%s') { wrappers { buildName('%s') } }", jobName, buildName);
Job seed = createSeedJobWithJobDsl(jobDslScript);
// Act
seed.startBuild().waitUntilFinished();
Job job = jenkins.jobs.get(Job.class, jobName);
Build build = job.startBuild().waitUntilFinished();
// Assert
build.open();
assertThat(build.getDisplayName(), containsString(buildName));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_create_job_with_github_repository.
/**
* Tests whether a github project is set to a job created by JobDsl when a github repository name
* is set to this job and the seed job is build.
*/
@Test
@WithPlugins({ "git", "github" })
public void should_create_job_with_github_repository() {
// Arrange
String jobName = "MyJob";
String gitProject = "jenkinsci/job-dsl-plugin";
String hrefLocator = "https://github.com/jenkinsci/job-dsl-plugin/";
Job seed = createSeedJobWithJobDsl(String.format("job('%s') { scm { github('%s') } }", jobName, gitProject));
// Act
seed.startBuild().waitUntilFinished();
Job job = jenkins.jobs.get(Job.class, jobName);
// Assert
job.open();
assertThat(driver, hasElement(by.href(hrefLocator)));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method should_unstable_on_deprecated_features.
/**
* Verifies whether the build will be marked as unstable if deprecated
* features are used.
* By default, only a warning is printed to the build log.
* If the function is used, the build will be marked as unstable.
*/
@Test
@WithPlugins("config-file-provider")
public void should_unstable_on_deprecated_features() {
FreeStyleJob seedJob = createSeedJob();
JobDslBuildStep jobDsl = seedJob.addBuildStep(JobDslBuildStep.class);
jobDsl.setScript("customConfigFile('New_Config_File')");
seedJob.save();
Build build = seedJob.scheduleBuild().shouldSucceed();
assertThat(build.getConsole(), containsString("Warning: (script, line 1) customConfigFile is deprecated"));
seedJob.configure(() -> jobDsl.setUnstableOnDeprecation(true));
build = seedJob.scheduleBuild().shouldBeUnstable();
assertThat(build.getConsole(), containsString("Warning: (script, line 1) customConfigFile is deprecated"));
}
use of org.jenkinsci.test.acceptance.junit.WithPlugins in project acceptance-test-harness by jenkinsci.
the class JobDslPluginTest method job_filters_status_failed_exclude_matched.
/**
* This test creates a job and runs a build which fails. Afterwards 4 new jobs get created as well as a listView.
* The job filter of the listView is set to not show jobs which build status is 'FAILED'.
*/
@Test
@WithPlugins("view-job-filters")
public void job_filters_status_failed_exclude_matched() {
Job failedJob = createJobThatFails();
List<Job> jobs = createAmountOfJobs(4, true);
String jobDslScript = "listView('" + LIST_VIEW_NAME + "') {\n" + " columns {\n" + " name()\n" + " }\n" + " jobs{\n" + " names('" + failedJob.name + "','" + jobs.get(0).name + "','" + jobs.get(1).name + "','" + jobs.get(2).name + "','" + jobs.get(3).name + "')\n" + " }\n" + " jobFilters {\n" + " status {\n" + " matchType(MatchType.EXCLUDE_MATCHED)\n" + " status(Status.FAILED)\n" + " }\n" + " }\n" + "}";
View view = openNewlyCreatedListView(jobDslScript, LIST_VIEW_NAME);
assertThat(view, not(containsJob(failedJob)));
assertThat(view, containsJob(jobs.get(0)));
assertThat(view, containsJob(jobs.get(1)));
assertThat(view, containsJob(jobs.get(2)));
assertThat(view, containsJob(jobs.get(3)));
}
Aggregations