hudson.tasks.test
Class TestResultParser

java.lang.Object
  extended by hudson.tasks.test.TestResultParser
All Implemented Interfaces:
ExtensionPoint
Direct Known Subclasses:
DefaultTestResultParserImpl, JUnitParser

public abstract class TestResultParser
extends Object
implements ExtensionPoint

Parses test result files and builds in-memory representation of it as TestResult.

This extension point encapsulates the knowledge of a particular test report format and its parsing process, thereby improving the pluggability of test result parsing; integration with a new test tool can be done by just writing a parser, without writing a custom Publisher, and the test reports are displayed with the default UI and recognized by the rest of Hudson as test reports.

Most typical implementations of this class should extend from DefaultTestResultParserImpl, which handles a set of default error checks on user inputs.

Parsers are stateless, and the parse(String, hudson.model.AbstractBuild, hudson.Launcher, hudson.model.TaskListener) method can be concurrently invoked by multiple threads for different builds.

Since:
1.343
See Also:
DefaultTestResultParserImpl

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Constructor Summary
TestResultParser()
           
 
Method Summary
static ExtensionList<TestResultParser> all()
          All registered TestResultParsers
 String getDisplayName()
          Returns a human readable name of the parser, like "JUnit Parser".
 String getTestResultLocationMessage()
          This text is used in the UI prompt for the GLOB that specifies files to be parsed by this parser.
abstract  TestResult parse(String testResultLocations, AbstractBuild build, Launcher launcher, TaskListener listener)
          Parses the specified set of files and builds a TestResult object that represents them.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestResultParser

public TestResultParser()
Method Detail

getDisplayName

public String getDisplayName()
Returns a human readable name of the parser, like "JUnit Parser".


getTestResultLocationMessage

public String getTestResultLocationMessage()
This text is used in the UI prompt for the GLOB that specifies files to be parsed by this parser. For example, "JUnit XML reports:"


all

public static ExtensionList<TestResultParser> all()
All registered TestResultParsers


parse

public abstract TestResult parse(String testResultLocations,
                                 AbstractBuild build,
                                 Launcher launcher,
                                 TaskListener listener)
                          throws InterruptedException,
                                 IOException
Parses the specified set of files and builds a TestResult object that represents them.

The implementation is encouraged to do the following:

Parameters:
testResultLocations - GLOB pattern relative to the workspace that specifies the locations of the test result files. Never null.
build - Build for which these tests are parsed. Never null.
launcher - Can be used to fork processes on the machine where the build is running. Never null.
listener - Use this to report progress and other problems. Never null.
Throws:
InterruptedException - If the user cancels the build, it will be received as a thread interruption. Do not catch it, and instead just forward that through the call stack.
IOException - If you don't care about handling exceptions gracefully, you can just throw IOException and let the default exception handling in Hudson takes care of it.
AbortException - If you encounter an error that you handled gracefully, throw this exception and Hudson will not show a stack trace.


Copyright © 2004-2013 Hudson. All Rights Reserved.