Skip to content

Commit

Permalink
Added red testcase for JENKINS-29649 + Jenkins2 pipeline job.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Ponomarev committed Aug 23, 2016
1 parent 349916a commit 170bfce
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
15 changes: 14 additions & 1 deletion pom.xml
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.3</version><!-- which version of Jenkins is this plugin
<version>1.637</version><!-- which version of Jenkins is this plugin
built against? -->
</parent>

Expand Down Expand Up @@ -104,6 +104,19 @@
<artifactId>junit</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.12</version>
<scope>test</scope>
</dependency>

</dependencies>

<repositories>
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/org/tap4j/plugin/util/GraphHelper.java
Expand Up @@ -27,13 +27,6 @@
import hudson.util.ColorPalette;
import hudson.util.ShiftedCategoryAxis;
import hudson.util.StackedAreaRenderer2;

import java.awt.Color;
import java.awt.Paint;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
Expand All @@ -55,6 +48,11 @@
import org.tap4j.plugin.TapBuildAction;
import org.tap4j.plugin.TapResult;

import java.awt.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* Helper class for trend graph generation.
*
Expand Down
39 changes: 27 additions & 12 deletions src/test/java/org/tap4j/plugin/PublishersCombinationTest.java
Expand Up @@ -25,7 +25,7 @@

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.Project;
import org.junit.Before;
import hudson.model.TopLevelItem;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
Expand All @@ -37,30 +37,42 @@ public class PublishersCombinationTest {

@Rule
public JenkinsRule rule = new JenkinsRule();
private Project project;

@Before
public void setUp() throws Exception {
@Issue("JENKINS-29649")
@LocalData
@Test
public void combinedWithJunitBasic() throws Exception {

project = (Project) rule.jenkins.getItem("multiPublish");
Project project = (Project) rule.jenkins.getItem("multiPublish");

// Validate that there are test results where I expect them to be:
JenkinsRule.WebClient wc = rule.createWebClient();

// On the project page:
HtmlPage projectPage = wc.getPage(project);

assertJunitPart(projectPage, 3, 4);
assertTapPart(projectPage, 3);
}

@Issue("JENKINS-29649")
@LocalData
@Test
public void combinedWithJunit() throws Exception {
public void combinedWithJunitPipeline() throws Exception {

TopLevelItem project = rule.jenkins.getItem("testPipeline");

// Validate that there are test results where I expect them to be:
JenkinsRule.WebClient wc = rule.createWebClient();

// On the project page:
HtmlPage projectPage = wc.getPage(project);

assertJunitPart(projectPage);
assertTapPart(projectPage);
assertJunitPart(projectPage, 15, 7);
assertTapPart(projectPage, 15);
}

private void assertJunitPart(HtmlPage page) {
private void assertJunitPart(HtmlPage page, int buildNumber, int testsTotal) {

// we should have a link that reads "Latest Test Result"
// that link should go to http://localhost:8080/job/breakable/lastBuild/testReport/
Expand All @@ -72,15 +84,18 @@ private void assertJunitPart(HtmlPage page) {
rule.assertXPath(page, "//img[@src='test/trend']");

// superficially assert that the number of tests was correct
rule.assertXPath(page, "//area[@title='#3: 4 tests' and @href='3/testReport/']");
rule.assertXPath(
page,
String.format("//area[@title='#%1$s: %2$s tests' and @href='%1$s/testReport/']", buildNumber, testsTotal)
);
}

private void assertTapPart(HtmlPage page) {
private void assertTapPart(HtmlPage page, int buildNumber) {

// there should be a TAP result trend graph
rule.assertXPath(page, "//img[@src='tapResults/graph']");

// superficially assert that the number of tests was correct
rule.assertXPath(page, "//area[@title='1 Skip(s)' and @href='3/tapResults/']");
rule.assertXPath(page, String.format("//area[@title='1 Skip(s)' and @href='%s/tapResults/']", buildNumber));
}
}
Binary file not shown.

0 comments on commit 170bfce

Please sign in to comment.