Class TestRunner

  • Direct Known Subclasses:
    DefaultTestRunner

    public abstract class TestRunner
    extends java.lang.Object
    TestRunner is the abstract base class providing the ability to control how tests are run. A default is provided that executes each test by means of a script class.

    If a test suite does not wish tom use the default test runner, it should provide its own implementation of this class. The primary method which should be implemented is runTests(java.util.Iterator<com.sun.javatest.TestDescription>).

    • Constructor Detail

      • TestRunner

        public TestRunner()
    • Method Detail

      • getWorkDirectory

        public WorkDirectory getWorkDirectory()
        Get the work directory to be used to store the test results generated by this test runner.
        Returns:
        the work directory used to store the test results generated by this test runner
      • getTestSuite

        public TestSuite getTestSuite()
        Get the test suite containing the tests to be run by this test runner.
        Returns:
        the test suite containing the tests to be run by this test runner
      • getBackupPolicy

        public BackupPolicy getBackupPolicy()
        Get the backup policy to be used when creating the test result files generated by this test runner.
        Returns:
        the backup policy to be used when creating the test result files generated by this test runner
        See Also:
        TestResult.writeResults(WorkDirectory, BackupPolicy)
      • getEnvironment

        public TestEnvironment getEnvironment()
        Get the test environment to be used to execute the tests that will be run by this test runner.
        Returns:
        the test environment to be used to execute the tests that will be run by this test runner
        See Also:
        getEnvironment()
      • getExcludedTestCases

        public java.lang.String[] getExcludedTestCases​(TestDescription td)
        Get the names of the test cases to be excluded when running a specific test.
        Parameters:
        td - the test for which the excluded test cases should be obtained
        Returns:
        the names of the test cases to be excluded when running a specific test. The result is null if the test is not found or is completely excluded without specifying test cases. This may be a mix of single TC strings or a comma separated list of them.
      • getConcurrency

        public int getConcurrency()
        Get the concurrency to be used when running the tests, if applicable.
        Returns:
        the concurrency to be used when running the tests, if applicable
        See Also:
        getConcurrency()
      • runTests

        protected abstract boolean runTests​(java.util.Iterator<TestDescription> testIter)
                                     throws java.lang.InterruptedException
        Run the tests obtained from an iterator. The iterator returns TestDescription objects for the tests that have been selected to be run. The iterator supports the standard hasNext() and next() methods; it does not support remove(), which throws UnsupportedOperationException. Each test description gives the details of the test to be run. As each test is started, the implementation of this method must create a new TestResult object and call notifyStartingTest(com.sun.javatest.TestResult). When the test completes (however it completes) the implementation of this method must call notifyFinishedTest(com.sun.javatest.TestResult).
        Parameters:
        testIter - the iterator to be used to obtain the tests to be run
        Returns:
        true if and only if all the tests executed successfully and passed
        Throws:
        java.lang.InterruptedException - if the test run was interrupted
      • notifyStartingTest

        protected void notifyStartingTest​(TestResult tr)
        This method must be called as each test is started, to notify any registered observers.
        Parameters:
        tr - the TestResult object for the test that has been started
        See Also:
        Harness.Observer
      • notifyFinishedTest

        protected void notifyFinishedTest​(TestResult tr)
        This method must be called when each test is finished, to notify any registered observers.
        Parameters:
        tr - the TestResult object for the test that has been started
        See Also:
        Harness.Observer