hudson.tasks.junit
Class TestResult

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.tasks.junit.TestObject
          extended by hudson.tasks.test.TestObject
              extended by hudson.tasks.test.TestResult
                  extended by hudson.tasks.test.TabulatedResult
                      extended by hudson.tasks.test.MetaTabulatedResult
                          extended by hudson.tasks.junit.TestResult
All Implemented Interfaces:
ModelObject, SearchableModelObject, SearchItem, Serializable

public final class TestResult
extends MetaTabulatedResult

Root of all the test results for one build.

Author:
Kohsuke Kawaguchi
See Also:
Serialized Form

Constructor Summary
TestResult()
          Creates an empty result.
TestResult(long buildTime, org.apache.tools.ant.DirectoryScanner results)
          Deprecated. 
TestResult(long buildTime, org.apache.tools.ant.DirectoryScanner results, boolean keepLongStdio)
          Collect reports from the given DirectoryScanner, while filtering out all files that were created before the given time.
 
Method Summary
 PackageResult byPackage(String packageName)
           
 TestResult findCorrespondingResult(String id)
          Find the test result corresponding to the one identified by id> withint this test result.
 void freeze(TestResultAction parent)
          Builds up the transient part of the data structure from results parsed so far.
 Collection<PackageResult> getChildren()
          Gets the child test result objects.
 String getChildTitle()
           
 String getDisplayName()
           
 float getDuration()
          Time it took to run this test.
 Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 String getErrorDetails()
          If there was an error or a failure, this is the text from the message.
 String getErrorStackTrace()
          If there was an error or a failure, this is the stack trace, or otherwise null.
 int getFailCount()
          Gets the total number of failed tests.
 int getFailedSince()
          If this test failed, then return the build number when this test started failing.
 Run<?,?> getFailedSinceRun()
          If this test failed, then return the run when this test started failing.
 List<CaseResult> getFailedTests()
          All failed tests.
 String getName()
          Gets the name of this object.
 AbstractBuild<?,?> getOwner()
           
 TestObject getParent()
          Reverse pointer of TabulatedResult.getChildren().
 AbstractTestResultAction getParentAction()
          Returns the action that points to the top level test result includes this test result.
 int getPassCount()
          Gets the total number of passed tests.
 Collection<? extends TestResult> getPassedTests()
          Gets the "children" of this test result that passed
 int getSkipCount()
          Gets the total number of skipped tests.
 Collection<? extends TestResult> getSkippedTests()
          Gets the "children" of this test result that were skipped
 String getStderr()
          The stderr of this test.
 String getStdout()
          The stdout of this test.
 SuiteResult getSuite(String name)
           
 Collection<SuiteResult> getSuites()
           
 TestResult getTestResult()
          Returns the top level test result data.
 String getTitle()
          Gets the human readable title of this result object.
 boolean hasChildren()
          Whether this test result has children.
 boolean isEmpty()
          Returns true if this doesn't have any any test results.
 boolean isPassed()
           
 void parse(File reportFile)
          Parses an additional report file.
 void parse(long buildTime, org.apache.tools.ant.DirectoryScanner results)
          Collect reports from the given DirectoryScanner, while filtering out all files that were created before the given time.
 void parse(long buildTime, File baseDir, String[] reportFiles)
          Collect reports from the given report files, while filtering out all files that were created before the given time.
 void parse(long buildTime, Iterable<File> reportFiles)
          Collect reports from the given report files
 void setParent(TestObject parent)
          Sets the parent test result
 void setParentAction(AbstractTestResultAction action)
          If the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.
 void tally()
          Recount my children.
 
Methods inherited from class hudson.tasks.test.TestResult
annotate, getBuildResult, getPreviousResult, getResultInBuild, toPrettyString
 
Methods inherited from class hudson.tasks.test.TestObject
doSubmitDescription, getApi, getDescription, getDurationString, getHistory, getId, getRelativePathFrom, getSafeName, getSearchUrl, getTestAction, getTestActions, getTestResultAction, getTopLevelTestResult, getTotalCount, getUrl, safe, setDescription, uniquifyName
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestResult

public TestResult()
Creates an empty result.


TestResult

@Deprecated
public TestResult(long buildTime,
                             org.apache.tools.ant.DirectoryScanner results)
           throws IOException
Deprecated. 

Throws:
IOException

TestResult

public TestResult(long buildTime,
                  org.apache.tools.ant.DirectoryScanner results,
                  boolean keepLongStdio)
           throws IOException
Collect reports from the given DirectoryScanner, while filtering out all files that were created before the given time.

Parameters:
keepLongStdio - if true, retain a suite's complete stdout/stderr even if this is huge and the suite passed
Throws:
IOException
Since:
1.358
Method Detail

getParent

public TestObject getParent()
Description copied from class: TestObject
Reverse pointer of TabulatedResult.getChildren().

Specified by:
getParent in class TestObject

setParent

public void setParent(TestObject parent)
Description copied from class: TestResult
Sets the parent test result

Overrides:
setParent in class TestResult

getTestResult

public TestResult getTestResult()
Description copied from class: TestObject
Returns the top level test result data.

Overrides:
getTestResult in class TestObject

parse

public void parse(long buildTime,
                  org.apache.tools.ant.DirectoryScanner results)
           throws IOException
Collect reports from the given DirectoryScanner, while filtering out all files that were created before the given time.

Throws:
IOException

parse

public void parse(long buildTime,
                  File baseDir,
                  String[] reportFiles)
           throws IOException
Collect reports from the given report files, while filtering out all files that were created before the given time.

Throws:
IOException
Since:
1.426

parse

public void parse(long buildTime,
                  Iterable<File> reportFiles)
           throws IOException
Collect reports from the given report files

Throws:
IOException
Since:
1.500

parse

public void parse(File reportFile)
           throws IOException
Parses an additional report file.

Throws:
IOException

getDisplayName

public String getDisplayName()

getOwner

public AbstractBuild<?,?> getOwner()
Specified by:
getOwner in class TestObject

findCorrespondingResult

public TestResult findCorrespondingResult(String id)
Description copied from class: TestObject
Find the test result corresponding to the one identified by id> withint this test result.

Specified by:
findCorrespondingResult in class TestObject
Parameters:
id - The path to the original test result
Returns:
A corresponding test result, or null if there is no corresponding result.

getTitle

public String getTitle()
Description copied from class: TestResult
Gets the human readable title of this result object.

Overrides:
getTitle in class TestResult

getChildTitle

public String getChildTitle()
Overrides:
getChildTitle in class TabulatedResult

getDuration

@Exported(visibility=999)
public float getDuration()
Description copied from class: TestResult
Time it took to run this test. In seconds.

Overrides:
getDuration in class TestResult

getPassCount

@Exported(visibility=999)
public int getPassCount()
Description copied from class: TestResult
Gets the total number of passed tests.

Overrides:
getPassCount in class TestResult

getFailCount

@Exported(visibility=999)
public int getFailCount()
Description copied from class: TestResult
Gets the total number of failed tests.

Overrides:
getFailCount in class TestResult

getSkipCount

@Exported(visibility=999)
public int getSkipCount()
Description copied from class: TestResult
Gets the total number of skipped tests.

Overrides:
getSkipCount in class TestResult

isEmpty

@Exported(visibility=999)
public boolean isEmpty()
Returns true if this doesn't have any any test results.

Since:
1.511

getFailedTests

public List<CaseResult> getFailedTests()
Description copied from class: MetaTabulatedResult
All failed tests.

Specified by:
getFailedTests in class MetaTabulatedResult
Returns:
the children of this test result, if any, or an empty collection

getPassedTests

public Collection<? extends TestResult> getPassedTests()
Gets the "children" of this test result that passed

Overrides:
getPassedTests in class TestResult
Returns:
the children of this test result, if any, or an empty collection

getSkippedTests

public Collection<? extends TestResult> getSkippedTests()
Gets the "children" of this test result that were skipped

Overrides:
getSkippedTests in class TestResult
Returns:
the children of this test result, if any, or an empty list

getFailedSince

public int getFailedSince()
If this test failed, then return the build number when this test started failing.

Overrides:
getFailedSince in class TestResult

getFailedSinceRun

public Run<?,?> getFailedSinceRun()
If this test failed, then return the run when this test started failing.

Overrides:
getFailedSinceRun in class TestResult

getStdout

public String getStdout()
The stdout of this test.

Depending on the tool that produced the XML report, this method works somewhat inconsistently. With some tools (such as Maven surefire plugin), you get the accurate information, that is the stdout from this test case. With some other tools (such as the JUnit task in Ant), this method returns the stdout produced by the entire test suite.

If you need to know which is the case, compare this output from SuiteResult.getStdout().

Overrides:
getStdout in class TestResult
Since:
1.294

getStderr

public String getStderr()
The stderr of this test.

Overrides:
getStderr in class TestResult
Since:
1.294
See Also:
getStdout()

getErrorStackTrace

public String getErrorStackTrace()
If there was an error or a failure, this is the stack trace, or otherwise null.

Overrides:
getErrorStackTrace in class TestResult

getErrorDetails

public String getErrorDetails()
If there was an error or a failure, this is the text from the message.

Overrides:
getErrorDetails in class TestResult

isPassed

public boolean isPassed()
Overrides:
isPassed in class TestResult
Returns:
true if the test was not skipped and did not fail, false otherwise.

getChildren

public Collection<PackageResult> getChildren()
Description copied from class: TabulatedResult
Gets the child test result objects.

Specified by:
getChildren in class TabulatedResult
See Also:
TestObject.getParent()

hasChildren

public boolean hasChildren()
Whether this test result has children.

Specified by:
hasChildren in class TabulatedResult

getSuites

@Exported(inline=true,
          visibility=9)
public Collection<SuiteResult> getSuites()

getName

public String getName()
Description copied from class: TestObject
Gets the name of this object.

Overrides:
getName in class TestObject

getDynamic

public Object getDynamic(String token,
                         org.kohsuke.stapler.StaplerRequest req,
                         org.kohsuke.stapler.StaplerResponse rsp)
Overrides:
getDynamic in class TestObject

byPackage

public PackageResult byPackage(String packageName)

getSuite

public SuiteResult getSuite(String name)

setParentAction

public void setParentAction(AbstractTestResultAction action)
Description copied from class: TestResult
If the concept of a parent action is important to a subclass, then it should provide a non-noop implementation of this method.

Overrides:
setParentAction in class TestResult

getParentAction

public AbstractTestResultAction getParentAction()
Description copied from class: TestResult
Returns the action that points to the top level test result includes this test result.

Overrides:
getParentAction in class TestResult
Returns:

tally

public void tally()
Recount my children.

Overrides:
tally in class TestResult

freeze

public void freeze(TestResultAction parent)
Builds up the transient part of the data structure from results parsed so far.

After the data is frozen, more files can be parsed and then freeze can be called again.



Copyright © 2004-2013. All Rights Reserved.