Search in sources :

Example 51 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.

the class MissionControlTest method testBuildHistory.

/**
 * Test Case: Check the existence and size of the build history, as well as
 * the correct highlighting of the builds.
 */
@Test
public void testBuildHistory() {
    // Create new mission control view and configure it
    int historySize = 8;
    MissionControlView view = jenkins.views.create(MissionControlView.class, "mission-control-sample-view");
    view.configure();
    view.setHideBuildHistory(false);
    view.setHistorySize(historySize);
    view.save();
    String strSimpleJob = "simple-job";
    String strFailedJob = "simple-failed-job";
    // Create new freestyle job and build it n-times
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class, strSimpleJob);
    for (int i = 0; i < historySize; ++i) {
        job.startBuild().waitUntilFinished();
    }
    job = jenkins.jobs.create(FreeStyleJob.class, strFailedJob);
    job.configure();
    // Add invalid shell build step to cause the job to fail
    job.addShellStep("sh <");
    job.save();
    job.startBuild().waitUntilFinished();
    // Open mission control view and assert that no build entries are being displayed
    // (after the creation of a new mission control view the configuration needs to be reloaded)
    view.open();
    assertThat(view.getBuildHistoryArea().getBuildHistorySize(), is(0));
    // Reload configuration (alternative: jenkins.restart(), very inefficient for this task)
    view.reloadConfiguration();
    // Open mission control view again and assert that the n-builds are being displayed now
    view.open();
    assertThat(view.getBuildHistoryArea().getBuildHistorySize(), is(historySize));
    // Check for correct highlighting of the builds
    // Also, according to the made settings, there should be 1 failed and historySize - 1 successful builds
    // in the build history
    assertThat(view.getBuildHistoryArea().getFailedBuildsOfJob(strFailedJob), hasSize(1));
    assertThat(view.getBuildHistoryArea().getSuccessfulBuildsOfJob(strSimpleJob), hasSize(historySize - 1));
}
Also used : MissionControlView(org.jenkinsci.test.acceptance.plugins.mission_control.MissionControlView) Matchers.containsString(org.jenkinsci.test.acceptance.Matchers.containsString) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 52 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.

the class MultipleScmsPluginTest method checkout_several_scms.

@Test
public void checkout_several_scms() {
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    MultipleScms scms = job.useScm(MultipleScms.class);
    GitScm git = scms.addScm(GitScm.class);
    git.url("git://github.com/jenkinsci/acceptance-test-harness.git");
    git.localDir("git-project");
    SubversionScm svn = scms.addScm(SubversionScm.class);
    svn.url.set("http://svn.apache.org/repos/asf/subversion/trunk/build/");
    svn.local.set("svn-project");
    job.addShellStep("test -d svn-project/.svn && test -f git-project/pom.xml");
    job.save();
    job.startBuild().shouldSucceed();
}
Also used : SubversionScm(org.jenkinsci.test.acceptance.plugins.subversion.SubversionScm) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) GitScm(org.jenkinsci.test.acceptance.plugins.git.GitScm) MultipleScms(org.jenkinsci.test.acceptance.plugins.multiple_scms.MultipleScms) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 53 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.

the class DashboardViewPluginTest method latestsBuildsPortlet_correctJobLink.

@Test
public void latestsBuildsPortlet_correctJobLink() {
    DashboardView v = createDashboardView();
    LatestBuildsPortlet latestBuilds = v.addBottomPortlet(LatestBuildsPortlet.class);
    v.save();
    FreeStyleJob job = createFreeStyleJob();
    buildSuccessfulJob(job);
    v.open();
    latestBuilds.openJob(job.name);
    assertThat(driver, hasContent("Project " + job.name));
}
Also used : LatestBuildsPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.LatestBuildsPortlet) DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 54 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.

the class FindBugsPluginTest method should_link_to_source_code_in_real_project.

/**
 * Builds a freestyle project and checks if new warning are displayed.
 */
@Test
public void should_link_to_source_code_in_real_project() {
    FreeStyleJob job = createJob(jenkins, "/findbugs_plugin/sample_findbugs_project", FreeStyleJob.class, FindBugsFreestyleSettings.class, settings -> settings.pattern.set("target/findbugsXml.xml"));
    setMavenGoal(job, "clean package findbugs:findbugs");
    Build build = buildSuccessfulJob(job);
    assertThatFindBugsResultExists(job, build);
    build.open();
    FindBugsAction action = new FindBugsAction(build);
    action.open();
    assertThat(action.getNumberOfNewWarnings(), is(1));
    verifySourceLine(action, "Main.java", 18, "18         if(o == null) {", "Redundant nullcheck of o, which is known to be non-null in Main.main(String[])");
}
Also used : FindBugsAction(org.jenkinsci.test.acceptance.plugins.findbugs.FindBugsAction) Build(org.jenkinsci.test.acceptance.po.Build) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Test(org.junit.Test)

Example 55 with FreeStyleJob

use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.

the class FindBugsPluginTest 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);
    editJob("/findbugs_plugin/forSecondRun/findbugsXml.xml", false, job, FindBugsFreestyleSettings.class);
    Build lastBuild = buildSuccessfulJob(job);
    assertThatFindBugsResultExists(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

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