Skip to content
Permalink
Browse files

Added: JENKINS-20438 - Make it an option to show failed builds in tre…

…nd graph
  • Loading branch information
nullin committed Feb 9, 2014
1 parent 5b93373 commit f984cfafde186d3e1f3a779fccb8a2c61a20007d
1 README
@@ -20,6 +20,7 @@ Release Notes
* Fixed: JENKINS-19353 - Exception error message newlines are escaped
* Fixed: JENKINS-20968 - Doesn't resolve parameters in "TestNG XML report pattern" field
* Moved some configuration into Advanced section and cleaned up help sections
* Added: JENKINS-20438 - Make it an option to show failed builds in trend graph

### v1.5
* Fixed: JENKINS-19157 - Make st:bind work when Jenkins has jQuery plugin installed
@@ -37,17 +37,20 @@
public final boolean escapeTestDescp;
//should exception messages be HTML escaped or not
public final boolean escapeExceptionMsg;
//should failed builds be included in graphs or not
public final boolean showFailedBuilds;

@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

@DataBoundConstructor
public Publisher(String reportFilenamePattern,
boolean escapeTestDescp, boolean escapeExceptionMsg) {
public Publisher(String reportFilenamePattern, boolean escapeTestDescp,
boolean escapeExceptionMsg, boolean showFailedBuilds) {
reportFilenamePattern.getClass();
this.reportFilenamePattern = reportFilenamePattern;
this.escapeTestDescp = escapeTestDescp;
this.escapeExceptionMsg = escapeExceptionMsg;
this.showFailedBuilds = showFailedBuilds;
}

public BuildStepMonitor getRequiredMonitorService() {
@@ -68,7 +71,7 @@ public BuildStepMonitor getRequiredMonitorService() {
@Override
public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> project) {
Collection<Action> actions = new ArrayList<Action>();
actions.add(new TestNGProjectAction(project, escapeTestDescp, escapeExceptionMsg));
actions.add(new TestNGProjectAction(project, escapeTestDescp, escapeExceptionMsg, showFailedBuilds));
return actions;
}

@@ -24,8 +24,9 @@
*/
public class TestNGProjectAction extends TestResultProjectAction implements ProminentProjectAction {

private boolean escapeTestDescp;
private boolean escapeExceptionMsg;
private transient boolean escapeTestDescp;
private transient boolean escapeExceptionMsg;
private transient boolean showFailedBuilds;

/**
* Used to figure out if we need to regenerate the graphs or not.
@@ -35,10 +36,11 @@
private transient Map<String, Integer> requestMap = new HashMap<String, Integer>();

public TestNGProjectAction(AbstractProject<?, ?> project,
boolean escapeTestDescp, boolean escapeExceptionMsg) {
boolean escapeTestDescp, boolean escapeExceptionMsg, boolean showFailedBuilds) {
super(project);
this.escapeExceptionMsg = escapeExceptionMsg;
this.escapeTestDescp = escapeTestDescp;
this.showFailedBuilds = showFailedBuilds;
}

protected Class<TestNGTestResultBuildAction> getBuildActionClass() {
@@ -213,8 +215,13 @@ protected void populateDataSetBuilder(DataSetBuilder<String, ChartUtil.NumberOnl
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(build);
TestNGTestResultBuildAction action = build.getAction(getBuildActionClass());

if (build.getResult() == null || build.getResult().isWorseThan(Result.UNSTABLE)) {
//We don't want to add aborted, failed or builds with no results into the graph
if (build.getResult() == null || build.getResult().isWorseThan(Result.FAILURE)) {
//We don't want to add aborted or builds with no results into the graph
continue;
}

if (!showFailedBuilds && build.getResult().equals(Result.FAILURE)) {
//failed build and configuration states that we should skip this build
continue;
}

@@ -10,5 +10,8 @@
<f:entry title="Escape exception messages?" field="escapeExceptionMsg">
<f:checkbox name="testng.escapeExceptionMsg" default="true" />
</f:entry>
<f:entry title="Show failed builds in trend graph?" field="showFailedBuilds">
<f:checkbox name="testng.showFailedBuilds" default="false" />
</f:entry>
</f:advanced>
</j:jelly>
@@ -0,0 +1,12 @@
<div>
<b>Show Failed builds in Trend Graph?</b>
<p>If checked, the plug-in includes results from failed builds in the trend graph. (Disabled by default) </p>
<p><b>Note</b>:
<ul>
<li>If this is a maven build, it is better to configure the build step with
<code>-Dmaven.test.failure.ignore=true</code> option. This results in build with test failures
being marked as Unstable, thus distinguishing it from build that failed because of non test related issues</li>
<li>Even when this option is selected, failed builds with no results and aborted builds will not be displayed in graphs</li>
</ul>
</p>
</div>
@@ -1,5 +1,9 @@
package hudson.plugins.testng;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;

import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
@@ -10,10 +14,6 @@
import org.junit.Test;
import org.jvnet.hudson.test.HudsonTestCase;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@@ -69,7 +69,7 @@ public void testLocateReports() throws Exception {

@Test
public void testBuildAborted() throws Exception {
Publisher publisher = new Publisher("**/testng-results.xml", false, false);
Publisher publisher = new Publisher("**/testng-results.xml", false, false, false);
Launcher launcherMock = mock(Launcher.class);
AbstractBuild buildMock = mock(AbstractBuild.class);
BuildListener listenerMock = mock(BuildListener.class);
@@ -89,14 +89,14 @@ public void testBuildAborted() throws Exception {
@Test
public void testRoundTrip() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher before = new Publisher("", false, false);
Publisher before = new Publisher("", false, false, true);
p.getPublishersList().add(before);

submit(createWebClient().getPage(p,"configure").getFormByName("config"));

Publisher after = p.getPublishersList().get(Publisher.class);

assertEqualBeans(before, after, "reportFilenamePattern,escapeTestDescp,escapeExceptionMsg");
assertEqualBeans(before, after, "reportFilenamePattern,escapeTestDescp,escapeExceptionMsg,showFailedBuilds");
}

}
@@ -1,5 +1,7 @@
package hudson.plugins.testng;

import java.io.IOException;

import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
@@ -11,8 +13,6 @@
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestBuilder;

import java.io.IOException;

/**
* Tests for {@link TestNGProjectAction}
*
@@ -35,7 +35,7 @@
@Test
public void testSettings() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("some.xml", false, true);
Publisher publisher = new Publisher("some.xml", false, true, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -35,7 +35,7 @@
@Test
public void testBuildAction_1() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -124,7 +124,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testBuildAction_2() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -1,5 +1,13 @@
package hudson.plugins.testng.results;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.Launcher;
@@ -16,9 +24,6 @@
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestBuilder;

import java.io.IOException;
import java.util.*;

/**
* Tests for {@link ClassResult}'s view page
*
@@ -43,7 +48,7 @@
@Test
public void testPrecheckinLegacyOpsClassResults() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -143,7 +148,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testClassResults() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -30,7 +30,7 @@
@Test
public void testEscapeExceptionMessageTrue() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, true /*escapeExpMsg*/);
Publisher publisher = new Publisher("testng.xml", false, true /*escapeExpMsg*/, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -58,7 +58,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testEscapeExceptionMessageFalse() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false /*escapeExpMsg*/);
Publisher publisher = new Publisher("testng.xml", false, false /*escapeExpMsg*/, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -85,7 +85,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testEscapeDescriptionFalse() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false /*escapeDescription*/, false);
Publisher publisher = new Publisher("testng.xml", false /*escapeDescription*/, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -113,7 +113,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testEscapeDescriptionTrue() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", true /*escapeDescription*/, false);
Publisher publisher = new Publisher("testng.xml", true /*escapeDescription*/, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -149,7 +149,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testMultilineDescriptionAndExceptionMessage() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false /*escapeDescription*/, false /*escapeException*/);
Publisher publisher = new Publisher("testng.xml", false /*escapeDescription*/, false /*escapeException*/, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -179,7 +179,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testReporterLogOutput() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -213,7 +213,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testMethodResults1() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -290,7 +290,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testMethodResults_dataProviderTests() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -366,7 +366,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testMethodResults_testInstanceNames() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -1,5 +1,10 @@
package hudson.plugins.testng.results;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.Launcher;
@@ -15,11 +20,6 @@
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestBuilder;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Tests for {@link PackageResult}'s view page
*
@@ -44,7 +44,7 @@
@Test
public void testPrecheckinPackageResults() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

@@ -149,7 +149,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
@Test
public void testMyPackagePackageResults() throws Exception {
FreeStyleProject p = createFreeStyleProject();
Publisher publisher = new Publisher("testng.xml", false, false);
Publisher publisher = new Publisher("testng.xml", false, false, false);
p.getPublishersList().add(publisher);
p.onCreatedFromScratch(); //to setup project action

0 comments on commit f984cfa

Please sign in to comment.
You can’t perform that action at this time.