use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method testStatisticsChart_failureAndSuccess.
@Test
public void testStatisticsChart_failureAndSuccess() throws IOException {
DashboardView v = createDashboardView();
TestStatisticsChartPortlet chart = v.addBottomPortlet(TestStatisticsChartPortlet.class);
v.save();
FreeStyleJob unstableFreeStyleJob = createUnstableFreeStyleJob();
FreeStyleJob successJob = createFreeStyleJob(job -> {
String resultFileName = "status.xml";
job.addShellStep("echo '<testsuite><testcase classname=\"\">" + "</testcase></testsuite>'>" + resultFileName);
job.addPublisher(JUnitPublisher.class).testResults.set(resultFileName);
});
buildSuccessfulJob(successJob);
buildUnstableJob(unstableFreeStyleJob);
v.open();
Map<Integer, Integer> colorsOccurrences = getColorDistributionOfSignificantColors(chart.getImage());
assertThat(colorsOccurrences.size(), is(2));
Iterator<Integer> colorIt = colorsOccurrences.values().iterator();
double failureSuccessRatio = Math.abs(((double) colorIt.next() / (double) colorIt.next()) - 1);
assertThat(failureSuccessRatio, lessThan(0.10));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method configureDashboardFilterOnlyActivatedJobs.
@Test
public void configureDashboardFilterOnlyActivatedJobs() {
DashboardView v = createDashboardView();
BuildStatisticsPortlet stats = v.addBottomPortlet(BuildStatisticsPortlet.class);
v.configure(() -> {
v.jobFilters.setStatusFilter(JobFiltersArea.StatusFilter.ENABLED);
});
final FreeStyleJob active = createFreeStyleJob();
final FreeStyleJob disabled = createFreeStyleJob();
buildSuccessfulJob(active);
buildSuccessfulJob(disabled);
v.open();
assertThat(stats.getNumberOfBuilds(JobType.TOTAL), is(2));
assertThat(stats.getNumberOfBuilds(JobType.DISABLED), is(0));
disabled.configure(disabled::disable);
v.open();
assertThat(stats.getNumberOfBuilds(JobType.TOTAL), is(1));
assertThat(stats.getNumberOfBuilds(JobType.DISABLED), is(0));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method unstableJobsPortlet_success.
@Test
public void unstableJobsPortlet_success() {
DashboardView v = createDashboardView();
UnstableJobsPortlet unstableJobsPortlet = v.addBottomPortlet(UnstableJobsPortlet.class);
unstableJobsPortlet.setShowOnlyFailedJobs(true);
v.save();
FreeStyleJob successfulJob = createFreeStyleJob();
buildSuccessfulJob(successfulJob);
assertJobInUnstableJobsPortlet(unstableJobsPortlet, successfulJob.name, false);
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class DashboardViewPluginTest method buildStatisticsPortlet_Percentage.
@Test
public void buildStatisticsPortlet_Percentage() {
DashboardView v = createDashboardView();
BuildStatisticsPortlet stats = v.addBottomPortlet(BuildStatisticsPortlet.class);
v.save();
FreeStyleJob success = createFreeStyleJob();
FreeStyleJob failing = createFailingFreeStyleJob();
FreeStyleJob unstable = createUnstableFreeStyleJob();
buildSuccessfulJob(success);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("100.0"));
buildFailingJob(failing);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("50.0"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("50.0"));
buildFailingJob(failing);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("33.33"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("66.67"));
buildUnstableJob(unstable);
v.open();
assertThat(stats.getPercentageOfBuilds(JobType.SUCCESS), is("25.0"));
assertThat(stats.getPercentageOfBuilds(JobType.FAILED), is("50.0"));
assertThat(stats.getPercentageOfBuilds(JobType.UNSTABLE), is("25.0"));
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class JUnitPluginTest method publish_parametrized_tests.
@Test
@Issue("JENKINS-22833")
public void publish_parametrized_tests() {
FreeStyleJob j = jenkins.jobs.create();
j.configure();
j.copyResource(resource("/junit/parameterized/junit.xml"));
j.copyResource(resource("/junit/parameterized/testng.xml"));
j.addPublisher(JUnitPublisher.class).testResults.set("*.xml");
j.save();
Build b = j.startBuild();
assertThat(b.getResult(), is("UNSTABLE"));
b.open();
clickLink("Test Result");
assertMessage("JUnit.testScore[0]", "expected:<42> but was:<0>");
assertMessage("JUnit.testScore[1]", "expected:<42> but was:<1>");
assertMessage("JUnit.testScore[2]", "expected:<42> but was:<2>");
assertMessage("TestNG.testScore", "expected:<42> but was:<0>");
assertMessage("TestNG.testScore", "expected:<42> but was:<1>");
assertMessage("TestNG.testScore", "expected:<42> but was:<2>");
}
Aggregations