com.google.testing.threadtester
Class ThreadedTestRunner

java.lang.Object
  extended by com.google.testing.threadtester.BaseThreadedTestRunner
      extended by com.google.testing.threadtester.ThreadedTestRunner

public class ThreadedTestRunner
extends BaseThreadedTestRunner

Runs a set of multithreaded tests. To create a multithreaded test, define a class with a public no-arg constructor, and a set of public no-arg instance methods annotated with the ThreadedTest annotation. The ThreadedTestRunner will create a new instance of the test class, and invoke each of the annotated methods in turn. For example, using JUnit 4 syntax:

 public class MyClassTest {
   public MyClassTest() {}

   &064;Test
   public void runThreadedTests {
     new ThreadedTestRunner().runTests(MyClassTest.class, MyClass.class);
   }

   &064;ThreadedTest
   public void testThreading {
     MyTest subject = new MyTest();
     ClassInstrumentationImpl instr =
         Instrumentation.getClassInstrumentation(MyClass.class);
     ...
   }
 

Before invoking each method, the runner will invoke the method with the ThreadedBefore annotation (if any). Setup code common the all of the tests can be added here. After invoking each method, the @{link ThreadedAfter} method will be invoked. This can be used to verify results, and to free resources.

Note that this class is normally used with standalone tests that use an InterleavedRunner or define their own Breakpoints and manage their own Threads. For simpler test cases, consider using the AnnotatedTestRunner.

Author:
alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
See Also:
BaseThreadedTestRunner, Instrumentation

Constructor Summary
ThreadedTestRunner()
           
 
Method Summary
protected  String getWrapperName()
          Gets the name of the wrapper class that runs the test.
 
Methods inherited from class com.google.testing.threadtester.BaseThreadedTestRunner
inThreadedTest, runTests, runTests, setDebug, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedTestRunner

public ThreadedTestRunner()
Method Detail

getWrapperName

protected String getWrapperName()
Description copied from class: BaseThreadedTestRunner
Gets the name of the wrapper class that runs the test. The named class should be a subclass of BaseTestWrapper.

This method is overridden by concrete implementations. An instance of the wrapper class will be created when BaseThreadedTestRunner.runTests(java.lang.Class, java.lang.Class...) is invoked, and the BaseTestWrapper.runTests(java.lang.Class, java.util.List) method will be invoked.

Specified by:
getWrapperName in class BaseThreadedTestRunner


Copyright © 2013. All Rights Reserved.