jenkinsci/jenkins — pull request #873 by nullin (2013-07-23 04:40:27+00:00)
Title: Make CaseResult non-final and it's ctor public

See the discussion at https://groups.google.com/forum/#!topic/jenkinsci-dev/CPab12692Qs.

I have been trying to figure out how to get email-ext plugin to support reporting on test failures reported as part of TestNG reports.

The problem stems from the fact that AbstractTestResultAction is supposed to be a generic class but it contains a method:

public List getFailedTests() {
return Collections.emptyList();
}

which returns CaseResult objects which are specific to JUnit. Also, CaseResult class is final and hence can't be extended.

TestNG plugin generates test result objects that extend hudson.tasks.test.TestResult but Email-ext and other plugins use the getFailedTests() methods and expect a list of CaseResult and then invoke specific methods on CaseResult object like getStatus, getClassname, getDisplayName etc.

Until Jenkins core developers get around to refactoring this code, I am hacking things to get this working. For other plugins that depend on getFailedTests() method, I'll return a list of objects from a class that extends CaseResult. For this, we need to make CaseResult non-final and it's constructor public.

Testing: Jenkins builds, TestNG and Email-ext plugins execute and generated email contains the correct information about failed tests.

(Didn't intend on changing the imports, IntelliJ was just being intelligent)