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));
}
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));
}
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));
}
Aggregations