Search in sources :

Example 1 with TestStatisticsChartPortlet

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet 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));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TestStatisticsChartPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet) Test(org.junit.Test)

Example 2 with TestStatisticsChartPortlet

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet in project acceptance-test-harness by jenkinsci.

the class DashboardViewPluginTest method testStatisticsChart_failure.

@Test
public void testStatisticsChart_failure() throws IOException {
    DashboardView v = createDashboardView();
    TestStatisticsChartPortlet chart = v.addBottomPortlet(TestStatisticsChartPortlet.class);
    v.save();
    FreeStyleJob unstableFreeStyleJob = createUnstableFreeStyleJob();
    buildUnstableJob(unstableFreeStyleJob);
    v.open();
    Map<Integer, Integer> colorsOccurrences = getColorDistributionOfSignificantColors(chart.getImage());
    assertThat(colorsOccurrences.size(), is(1));
    Integer color = colorsOccurrences.keySet().iterator().next();
    int blueComp = (color << 24) >>> 24;
    int greenComp = (color << 16) >>> 24;
    int redComp = (color << 8) >>> 24;
    assertThat(redComp, greaterThan(150));
    assertThat(redComp, greaterThan(blueComp));
    assertThat(redComp, greaterThan(greenComp));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TestStatisticsChartPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet) Test(org.junit.Test)

Example 3 with TestStatisticsChartPortlet

use of org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet in project acceptance-test-harness by jenkinsci.

the class DashboardViewPluginTest method testStatisticsChart_success.

@Test
public void testStatisticsChart_success() throws IOException {
    DashboardView v = createDashboardView();
    TestStatisticsChartPortlet chart = v.addBottomPortlet(TestStatisticsChartPortlet.class);
    v.save();
    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);
    v.open();
    Map<Integer, Integer> colorsOccurrences = getColorDistributionOfSignificantColors(chart.getImage());
    assertThat(colorsOccurrences.size(), is(1));
    Integer color = colorsOccurrences.keySet().iterator().next();
    int blueComp = (color << 24) >>> 24;
    int greenComp = (color << 16) >>> 24;
    int redComp = (color << 8) >>> 24;
    assertThat(blueComp, greaterThan(150));
    assertThat(blueComp, greaterThan(greenComp));
    assertThat(blueComp, greaterThan(redComp));
}
Also used : DashboardView(org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) TestStatisticsChartPortlet(org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet) Test(org.junit.Test)

Aggregations

DashboardView (org.jenkinsci.test.acceptance.plugins.dashboard_view.DashboardView)3 TestStatisticsChartPortlet (org.jenkinsci.test.acceptance.plugins.dashboard_view.TestStatisticsChartPortlet)3 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)3 Test (org.junit.Test)3