| java.lang.Object net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner
MultiThreadedTestRunner | public class MultiThreadedTestRunner (Code) | | A framework which allows for an array of tests to be
run asynchronously. TestCases should reference this class in a test
method.
Update for July 9, 2003: now, you can also register
TestRunner instances as monitors (request 771008); these run
parallel with the standard TestRunner instances, but they only quit
when all of the standard TestRunner instances end.
Fixed bugs 771000 and 771001: spawned threads are now Daemon threads,
and all "wild threads" (threads that just won't stop) are
Thread.stop()ed.
All these changes have made this class rather fragile, as there are
many threaded timing issues to deal with. Expect future refactoring
with backwards compatibility.
author: Matt Albrecht groboclown@users.sourceforge.net since: Jan 14, 2002 version: $Date: 2003/10/03 14:26:45 $ |
Inner Class :final public static class TestDeathException extends RuntimeException | |
MultiThreadedTestRunner | public MultiThreadedTestRunner(TestRunnable tr)(Code) | | Create a new utility instance with the given set of parallel runners.
All runners passed into this method must end on their own, else it's
an error.
|
MultiThreadedTestRunner | public MultiThreadedTestRunner(TestRunnable runners, TestRunnable monitors)(Code) | | Create a new utility instance with the given set of parallel runners
and a set of monitors. The runners must end on their own, but the
monitors can run until told to stop.
Parameters: runners - a non-null, non-empty collection of test runners. Parameters: monitors - a list of monitor runners, which may be null orempty. |
areThreadsFinished | boolean areThreadsFinished()(Code) | | Used by the TestRunnable instances to tell if the parallel execution
has stopped or is stopping.
|
handleException | void handleException(Throwable t)(Code) | | Handles an exception by sending them to the test results. Called by
runner or monitor threads.
|
interruptThreads | void interruptThreads()(Code) | | Stops all running test threads. Called by runner or monitor threads.
|
runTestRunnables | public void runTestRunnables() throws Throwable(Code) | | Run each test given in a separate thread. Wait for each thread
to finish running, then return.
As of July 9, 2003, this method will not wait forever, but rather
will wait for the internal maximum run time, which is by default
24 hours; for most unit testing scenarios, this is more than
sufficient.
exception: Throwable - thrown on a test run if a threaded taskthrows an exception. |
runTestRunnables | public void runTestRunnables(long maxTime) throws Throwable(Code) | | Runs each test given in a separate thread. Waits for each thread
to finish running (possibly killing them), then returns.
Parameters: runnables - the list of TestCaseRunnable objects to runasynchronously Parameters: maxTime - the maximum amount of milliseconds to wait forthe tests to run. If the time is <= 0, then the testswill run until they are complete. Otherwise, any threads thatdon't complete by the given number of milliseconds will be killed,and a failure will be thrown. exception: Throwable - thrown from the underlying tests if they happento cause an error. |
|
|