Class TestCases

java.lang.Object
com.sun.javatest.lib.TestCases

public class TestCases extends Object
A handler for the set of test cases in a test. Test cases are those methods with no args that return a status. Test cases can be explicitly selected into or excluded from the set.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Exception used to report internal errors.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an object to handle the test cases of the given test.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return an enumeration of the selected test cases, based on the select and exclude calls that have been made, if any.
    void
    exclude(String testCaseNames)
    Explicitly exclude a set of test cases by name.
    void
    exclude(String... testCaseNames)
    Explicitly exclude a set of test cases by name.
    Invoke each of the selected test cases, based upon the select and exclude calls that have been made, if any.
    protected void
    Print a stack trace for an exception to the log.
    void
    select(String testCaseNames)
    Explicitly select a set of test cases by name.
    void
    select(String... testCaseNames)
    Explicitly select a set of test cases by name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TestCases

      public TestCases(Test t, PrintWriter log)
      Create an object to handle the test cases of the given test.
      Parameters:
      t - The test containing the test cases.
      log - An optional stream to which to write log messages. Use null if messages are not desired.
  • Method Details

    • select

      public void select(String testCaseNames) throws TestCases.Fault
      Explicitly select a set of test cases by name. Subsequent calls are cumulative; if no selections are made, the default is all test cases are selected. Excluded tests will be excluded from the selection; the order of select and exclude calls does not matter.
      Parameters:
      testCaseNames - a comma-separated list of test cases names. Each name must identify a method in the test object, that takes no arguments and returns a status.
      Throws:
      TestCases.Fault - if any of the test case names are invalid.
    • select

      public void select(String... testCaseNames) throws TestCases.Fault
      Explicitly select a set of test cases by name. Subsequent calls are cumulative; if no selections are made, the default is all test cases are selected. Excluded tests will be excluded from the selection; the order of select and exclude calls does not matter.
      Parameters:
      testCaseNames - an array of test cases names. Each name must identify a method in the test object, that takes no arguments and returns a status.
      Throws:
      TestCases.Fault - if any of the test case names are invalid.
    • exclude

      public void exclude(String testCaseNames) throws TestCases.Fault
      Explicitly exclude a set of test cases by name. Subsequent calls are cumulative; by default, no test cases are excluded.
      Parameters:
      testCaseNames - a comma-separated list of test cases names. Each name must identify a method in the test object, that takes no arguments and returns a status.
      Throws:
      TestCases.Fault - if any of the test case names are invalid.
    • exclude

      public void exclude(String... testCaseNames) throws TestCases.Fault
      Explicitly exclude a set of test cases by name. Subsequent calls are cumulative; by default, no test cases are excluded.
      Parameters:
      testCaseNames - an array of test cases names. Each name must identify a method in the test object, that takes no arguments and returns a status.
      Throws:
      TestCases.Fault - if any of the test case names are invalid.
    • enumerate

      public Enumeration<Method> enumerate()
      Return an enumeration of the selected test cases, based on the select and exclude calls that have been made, if any.
      Returns:
      An enumeration of the test cases.
    • invokeTestCases

      public Status invokeTestCases()
      Invoke each of the selected test cases, based upon the select and exclude calls that have been made, if any. If the test object provides a public method StatusinvokeTestCase(Method) that method will be called to invoke the test cases; otherwise, the test cases will be invoked directly. It is an error if no test cases are selected, (or if they have all been excluded.)
      Returns:
      the combined result of executing all the test cases.
    • printStackTrace

      protected void printStackTrace(Throwable t)
      Print a stack trace for an exception to the log.
      Parameters:
      t - The Throwable for which to print the trace