Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed: JENKINS-18498 - hudson.tasks.test.AggregatedTestResultAction$1…
… cannot be cast to hudson.tasks.test.TestResult
  • Loading branch information
nullin committed Jun 30, 2013
1 parent 8c4cfe2 commit 8be94c3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
3 changes: 3 additions & 0 deletions README
Expand Up @@ -16,6 +16,9 @@ graph and all details about which tests that failed are also presented.
Release Notes
-------

### v1.2
* Fixed: JENKINS-18498 - hudson.tasks.test.AggregatedTestResultAction$1 cannot be cast to hudson.tasks.test.TestResult

### v1.1
* Fixed: JENKINS-16592 - Invalid URL in testngreport on tests execution history chart

Expand Down
32 changes: 30 additions & 2 deletions src/main/java/hudson/plugins/testng/results/BaseResult.java
@@ -1,7 +1,11 @@
package hudson.plugins.testng.results;

import java.io.Serializable;

import hudson.model.AbstractBuild;
import hudson.model.ModelObject;
import hudson.plugins.testng.TestNGTestResultBuildAction;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.TabulatedResult;
import hudson.tasks.test.TestResult;
import jenkins.model.Jenkins;
Expand All @@ -10,8 +14,6 @@
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;

import java.io.Serializable;

/**
* Base class that takes care of all the common functionality of the different kinds of
* test results.
Expand Down Expand Up @@ -78,6 +80,32 @@ public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp)
return null;
}

/**
* Explicit override here to ensure that when we are building TestNG reports,
* we are only working with TestNG results (and not results from other test reporters).
*
* Can get into a bad situation if the same job has configured JUnit and TestNG reports
*
* @return
*/
@Override
public AbstractTestResultAction getTestResultAction() {
AbstractBuild<?, ?> owner = getOwner();
if (owner != null) {
return owner.getAction(TestNGTestResultBuildAction.class);
}
return null;
}

/**
* @see BaseResult#getTestResultAction()
* @return
*/
@Override
public AbstractTestResultAction getParentAction() {
return getTestResultAction();
}

@Override
public TestResult findCorrespondingResult(String id) {
if (getId().equals(id) || id == null) {
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/hudson/plugins/testng/results/TestNGResult.java
@@ -1,12 +1,12 @@
package hudson.plugins.testng.results;

import java.io.Serializable;
import java.util.*;

import hudson.model.AbstractBuild;
import hudson.plugins.testng.PluginImpl;
import org.kohsuke.stapler.export.Exported;

import java.io.Serializable;
import java.util.*;

/**
* Represents all the results gathered for a single build (or a single suite,
* while parsing the test results)
Expand Down Expand Up @@ -228,11 +228,6 @@ public String getName() {
return name;
}

@Override
public AbstractBuild<?, ?> getOwner() {
return owner;
}

@Override
public BaseResult getParent() {
return null;
Expand Down

0 comments on commit 8be94c3

Please sign in to comment.