Package hudson.tasks.test
Class TestObject
java.lang.Object
hudson.model.AbstractModelObject
hudson.tasks.junit.TestObject
hudson.tasks.test.TestObject
- All Implemented Interfaces:
ModelObject,SearchableModelObject,SearchItem,Serializable
- Direct Known Subclasses:
TestResult
Base class for all test result objects.
For compatibility with code that expects this class to be in hudson.tasks.junit,
we've created a pure-abstract class, hudson.tasks.junit.TestObject. That
stub class is deprecated; instead, people should use this class.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.kohsuke.stapler.HttpResponsedoSubmitDescription(String description) abstract TestResultFind the test result corresponding to the one identified byidwithin this test result.getApi()Exposes this object through the remote API.abstract floatTime took to run this test.Returns the string representation of thegetDuration(), in a human readable format.getDynamic(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) abstract intGets the total number of failed tests.Gets the full name of this object.final StringgetId()getName()Gets the name of this object.abstract TestObjectReverse pointer ofTabulatedResult.getChildren().abstract intGets the total number of passed tests.abstract TestResultGets the counterpart of thisTestResultin the previous run.Computes the relative path to get to this test object fromit.getResultInBuild(AbstractBuild<?, ?> build) Deprecated.getResultInRun(Run<?, ?> run) Gets the counterpart of thisTestResultin the specified run.Gets the version ofgetName()that's URL-safe.abstract intGets the total number of skipped tests.<T> TgetTestAction(Class<T> klazz) Gets a test action of the class passed in.Get a list of all TestActions associated with this TestObject.Deprecated.This method returns a JUnit specific class.Subclasses may override this method if they are associated with a particular subclass of AbstractTestResultAction.Returns the top level test result data.intGets the total number of tests.getUrl()Returns the URL of thisTestObject, relative to the context root.static StringReplaces URL-unsafe characters.voidsetDescription(String description) protected final StringuniquifyName(Collection<? extends TestObject> siblings, String base) #2988: uniquifies agetSafeName()amongst children of the parent.Methods inherited from class hudson.tasks.junit.TestObject
getOwner, getRunMethods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.model.ModelObject
getDisplayNameMethods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
Constructor Details
-
TestObject
public TestObject()
-
-
Method Details
-
getParent
Reverse pointer ofTabulatedResult.getChildren().- Specified by:
getParentin classTestObject- Returns:
- the parent
TestObject.
-
getId
- Specified by:
getIdin classTestObject
-
getUrl
Description copied from class:TestObjectReturns the URL of thisTestObject, relative to the context root.- Specified by:
getUrlin classTestObject- Returns:
- String like "job/foo/32/testReport/junit/com.company/Class" with no trailing or leading slash.
-
getFullDisplayName
-
getTestResult
Deprecated.This method returns a JUnit specific class. UsegetTopLevelTestResult()instead for a more general interface.Returns the top level test result data.- Specified by:
getTestResultin classTestObject
-
getTopLevelTestResult
Returns the top level test result data.- Returns:
- the top level test result data.
-
getRelativePathFrom
Computes the relative path to get to this test object fromit. Ifitdoes not appear in the parent chain for this object, a relative path from the server root will be returned.- Parameters:
it- Target test object.- Returns:
- A relative path to this object, potentially from the top of the Hudson object model
-
getTestResultAction
Subclasses may override this method if they are associated with a particular subclass of AbstractTestResultAction.- Specified by:
getTestResultActionin classTestObject- Returns:
- the test result action that connects this test result to a particular build
-
getTestActions
Get a list of all TestActions associated with this TestObject.- Specified by:
getTestActionsin classTestObject
-
getTestAction
Gets a test action of the class passed in.- Specified by:
getTestActionin classTestObject- Type Parameters:
T- an instance of the class passed in- Parameters:
klazz- Type of the action to return.
-
getPreviousResult
Gets the counterpart of thisTestResultin the previous run.- Specified by:
getPreviousResultin classTestObject- Returns:
- null if no such counter part exists.
-
getResultInBuild
Deprecated.- Overrides:
getResultInBuildin classTestObject
-
getResultInRun
Gets the counterpart of thisTestResultin the specified run.- Overrides:
getResultInRunin classTestObject- Parameters:
run- The run for which the run is requested.- Returns:
- null if no such counter part exists.
-
findCorrespondingResult
Find the test result corresponding to the one identified byidwithin this test result.- Parameters:
id- The path to the original test result- Returns:
- A corresponding test result, or null if there is no corresponding result.
-
getDuration
public abstract float getDuration()Time took to run this test. In seconds.- Specified by:
getDurationin classTestObject- Returns:
- the time in seconds the test ran.
-
getDurationString
Returns the string representation of thegetDuration(), in a human readable format.- Specified by:
getDurationStringin classTestObject- Returns:
- a string representation of
TestObject.getDuration().
-
getDescription
- Specified by:
getDescriptionin classTestObject
-
setDescription
- Specified by:
setDescriptionin classTestObject
-
getApi
Exposes this object through the remote API.- Specified by:
getApiin classTestObject- Returns:
- the api for this test object.
-
getName
Gets the name of this object.- Specified by:
getNamein classTestObject- Returns:
- the name of this object.
-
getFullName
Gets the full name of this object.- Returns:
- the full name of this object.
- Since:
- 1.551
-
getSafeName
Gets the version ofgetName()that's URL-safe.- Specified by:
getSafeNamein classTestObject- Returns:
- the URL-safe name of this object.
-
getSearchUrl
- Specified by:
getSearchUrlin interfaceSearchItem- Specified by:
getSearchUrlin classTestObject
-
uniquifyName
#2988: uniquifies agetSafeName()amongst children of the parent.- Parameters:
siblings- Siblings of the currentbase- Prefix to use for the name.- Returns:
- an unique name amongst children of the parent.
-
safe
Replaces URL-unsafe characters. If s is an empty string, returns "(empty)" otherwise the generated URL would contain two slashes one after the other and getDynamic() would fail.- Parameters:
s- String to process.- Returns:
- the string with the unsafe characters replaced.
-
getPassCount
public abstract int getPassCount()Gets the total number of passed tests.- Specified by:
getPassCountin classTestObject- Returns:
- the total number of passed tests.
-
getFailCount
public abstract int getFailCount()Gets the total number of failed tests.- Specified by:
getFailCountin classTestObject- Returns:
- the total number of failed tests.
-
getSkipCount
public abstract int getSkipCount()Gets the total number of skipped tests.- Specified by:
getSkipCountin classTestObject- Returns:
- the total number of skipped tests.
-
getTotalCount
public int getTotalCount()Gets the total number of tests.- Specified by:
getTotalCountin classTestObject- Returns:
- the total number of tests.
-
getHistory
- Specified by:
getHistoryin classTestObject
-
getDynamic
-
doSubmitDescription
public org.kohsuke.stapler.HttpResponse doSubmitDescription(@QueryParameter String description) throws IOException - Throws:
IOException
-