One way to get all the case results is to iterate all the SuiteResults and
collect CaseResults from them:
List<CaseResult> allCaseResults = new ArrayList<CaseResult>();
for (SuiteResult suiteResult : testResult.getSuites()) {
allCaseResults.addAll(suiteResult.getCases());
}
On Thursday, October 3, 2013 3:43:24 AM UTC+4, Cletus D'Souza wrote:
>
> Hi All,
>
> Jenkins does a great job of parsing JUnit Test Results and publishing it
> for the build. I'd like to be able to tap into that framework and extract
> that information for my plugin.
>
> I've tried the following (with Jenkins 1.533):
>
> AbstractTestResultAction<?> atr = build.getTestResultAction(); // build
> is AbstractBuild<?, ?>
> TestResult tr= atr.findCorrespondingResult(testCaseID);
>
> Which results in the following exception:
> hudson.tasks.test.AggregatedTestResultAction$1 cannot be cast to
> hudson.tasks.test.TestResult
> java.lang.ClassCastException:
> hudson.tasks.test.AggregatedTestResultAction$1 cannot be cast to
> hudson.tasks.test.TestResult
> at
> hudson.tasks.test.AbstractTestResultAction.findCorrespondingResult(AbstractTestResultAction.java:183)
> at
> hudson.scm.IntegrityItemAction.updateTestResult(IntegrityItemAction.java:576)
>
> I can get the list of 'failed test results', but I can't seem to figure
> out how to get the same for passed/skipped:
>
> Logger.debug("Total tests run: " + testResult.getTotalCount());
> Logger.debug("Total passed count: " + (testResult.getTotalCount() -
> testResult.getFailCount() - testResult.getSkipCount()));
> Logger.debug("Total failed count: " + testResult.getFailCount());
> Logger.debug("Total skipped count: " + testResult.getSkipCount());
> if( testResult.getFailCount() > 0 )
> {
> List<CaseResult> resultList = testResult.getFailedTests();
> Logger.debug("Failed Test Details:");
> for( CaseResult caseResult : resultList )
> {
> Logger.debug(caseResult.getFullDisplayName() + " " +
> caseResult.getErrorDetails());
> }
> }
>
> Does someone have an example of how I can get the test results
> (passed/failed/skipped)?
>
> Thanks!
> Cletus
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.