Package com.clarkware.junitperf
Class ThreadedTestGroup
- java.lang.Object
-
- java.lang.ThreadGroup
-
- com.clarkware.junitperf.ThreadedTestGroup
-
- All Implemented Interfaces:
java.lang.Thread.UncaughtExceptionHandler
public class ThreadedTestGroup extends java.lang.ThreadGroup
TheThreadedTestGroup
is aThreadGroup
that catches and handles exceptions thrown by threads created and started byThreadedTest
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 Summary
Constructors Constructor Description ThreadedTestGroup(junit.framework.Test test)
Constructs aThreadedTestGroup
for the specified test.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setTestResult(junit.framework.TestResult result)
Sets the current test result.void
uncaughtException(java.lang.Thread t, java.lang.Throwable e)
Called when a thread in this thread group stops because of an uncaught exception.-
Methods inherited from class java.lang.ThreadGroup
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString
-
-
-
-
Method Detail
-
setTestResult
public void setTestResult(junit.framework.TestResult result)
Sets the current test result.- Parameters:
result
- Test result.
-
uncaughtException
public void uncaughtException(java.lang.Thread t, java.lang.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 anAssertionFailedError
, 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 interfacejava.lang.Thread.UncaughtExceptionHandler
- Overrides:
uncaughtException
in classjava.lang.ThreadGroup
- Parameters:
t
- Originating thread.e
- Uncaught exception.
-
-