TestFactory class creates thread-local TestSuite instances. This factory class should be used in cases when a stateful test is intended to be decorated by a LoadTest. A stateful test is defined as any test that defines test-specific state in its setUp() method.
Use of the TestFactory ensures that each thread spawned by a LoadTest contains its own TestSuite instance containing all tests defined in the specified TestCase class.
A typical usage scenario is as follows:
Test factory = new TestFactory(YourTestCase.class); LoadTest test = new LoadTest(factory, numberOfUsers, ...); ...
Of course, static variables cannot be protected externally, so tests intended to be run in a multi-threaded environment should ensure that the use of static variables is thread-safe.
This class is dependent on Java 2. For earlier platforms a local cache implementation should be changed to use, for example, a HashMap to track thread-local information.
@author Mike Clark @author Clarkware Consulting, Inc. @author Ervin Varga @see com.clarkware.junitperf.LoadTest | |