Class ThreadedTestGroup

java.lang.Object
java.lang.ThreadGroup
com.clarkware.junitperf.ThreadedTestGroup
All Implemented Interfaces:
Thread.UncaughtExceptionHandler

public class ThreadedTestGroup extends ThreadGroup
The ThreadedTestGroup is a ThreadGroup that catches and handles exceptions thrown by threads created and started by ThreadedTest instances.

If a thread managed by a ThreadedTestGroup throws an uncaught exception, then the exception is added to the current test's results and all other threads are immediately interrupted.

Author:
Ervin Varga, Mike Clark, Clarkware Consulting, Inc.
  • Constructor Details

    • ThreadedTestGroup

      public ThreadedTestGroup(junit.framework.Test test)
      Constructs a ThreadedTestGroup for the specified test.
      Parameters:
      test - Current test.
  • Method Details

    • setTestResult

      public void setTestResult(junit.framework.TestResult result)
      Sets the current test result.
      Parameters:
      result - Test result.
    • uncaughtException

      public void uncaughtException(Thread t, Throwable e)
      Called when a thread in this thread group stops because of an uncaught exception.

      If the uncaught exception is a ThreadDeath, then it is ignored. If the uncaught exception is an AssertionFailedError, then a failure is added to the current test's result. Otherwise, an error is added to the current test's result.

      Specified by:
      uncaughtException in interface Thread.UncaughtExceptionHandler
      Overrides:
      uncaughtException in class ThreadGroup
      Parameters:
      t - Originating thread.
      e - Uncaught exception.