Class TestObject

  • All Implemented Interfaces:
    ModelObject, SearchableModelObject, SearchItem, Serializable
    Direct Known Subclasses:
    TestResult

    @ExportedBean
    public abstract class TestObject
    extends TestObject
    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:
    Serialized Form
    • Constructor Detail

      • TestObject

        public TestObject()
    • Method Detail

      • getUrl

        public String getUrl()
        Description copied from class: TestObject
        Returns the URL of this TestObject, relative to the context root.
        Specified by:
        getUrl in class TestObject
        Returns:
        String like "job/foo/32/testReport/junit/com.company/Class" with no trailing or leading slash.
      • getFullDisplayName

        public String getFullDisplayName()
      • getTopLevelTestResult

        public TestResult getTopLevelTestResult()
        Returns the top level test result data.
        Returns:
        the top level test result data.
      • getRelativePathFrom

        public String getRelativePathFrom​(TestObject it)
        Computes the relative path to get to this test object from it. If it does 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

        public AbstractTestResultAction getTestResultAction()
        Subclasses may override this method if they are associated with a particular subclass of AbstractTestResultAction.
        Specified by:
        getTestResultAction in class TestObject
        Returns:
        the test result action that connects this test result to a particular build
      • getTestActions

        @Exported(visibility=3)
        public List<TestAction> getTestActions()
        Get a list of all TestActions associated with this TestObject.
        Specified by:
        getTestActions in class TestObject
      • getTestAction

        public <T> T getTestAction​(Class<T> klazz)
        Gets a test action of the class passed in.
        Specified by:
        getTestAction in class TestObject
        Type Parameters:
        T - an instance of the class passed in
        Parameters:
        klazz - Type of the action to return.
      • getResultInRun

        public TestResult getResultInRun​(Run<?,​?> run)
        Gets the counterpart of this TestResult in the specified run.
        Overrides:
        getResultInRun in class TestObject
        Parameters:
        run - The run for which the run is requested.
        Returns:
        null if no such counter part exists.
      • findCorrespondingResult

        public abstract TestResult findCorrespondingResult​(String id)
        Find the test result corresponding to the one identified by id within 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:
        getDuration in class TestObject
        Returns:
        the time in seconds the test ran.
      • getApi

        public Api getApi()
        Exposes this object through the remote API.
        Specified by:
        getApi in class TestObject
        Returns:
        the api for this test object.
      • getName

        public String getName()
        Gets the name of this object.
        Specified by:
        getName in class TestObject
        Returns:
        the name of this object.
      • getFullName

        public String getFullName()
        Gets the full name of this object.
        Returns:
        the full name of this object.
        Since:
        1.551
      • getSafeName

        public String getSafeName()
        Gets the version of getName() that's URL-safe.
        Specified by:
        getSafeName in class TestObject
        Returns:
        the URL-safe name of this object.
      • uniquifyName

        protected final String uniquifyName​(Collection<? extends TestObject> siblings,
                                            String base)
        #2988: uniquifies a getSafeName() amongst children of the parent.
        Parameters:
        siblings - Siblings of the current
        base - Prefix to use for the name.
        Returns:
        an unique name amongst children of the parent.
      • safe

        public static String safe​(String s)
        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:
        getPassCount in class TestObject
        Returns:
        the total number of passed tests.
      • getFailCount

        public abstract int getFailCount()
        Gets the total number of failed tests.
        Specified by:
        getFailCount in class TestObject
        Returns:
        the total number of failed tests.
      • getSkipCount

        public abstract int getSkipCount()
        Gets the total number of skipped tests.
        Specified by:
        getSkipCount in class TestObject
        Returns:
        the total number of skipped tests.
      • getTotalCount

        public int getTotalCount()
        Gets the total number of tests.
        Specified by:
        getTotalCount in class TestObject
        Returns:
        the total number of tests.
      • getDynamic

        public Object getDynamic​(String token,
                                 org.kohsuke.stapler.StaplerRequest req,
                                 org.kohsuke.stapler.StaplerResponse rsp)
      • doSubmitDescription

        public org.kohsuke.stapler.HttpResponse doSubmitDescription​(@QueryParameter
                                                                    String description)
                                                             throws IOException,
                                                                    javax.servlet.ServletException
        Throws:
        IOException
        javax.servlet.ServletException