com.google.testing.threadtester
Interface MainRunnable<T>

Type Parameters:
T - the type under test. It is expected that the runnable will invoke a method on this class.
All Superinterfaces:
ThrowingRunnable
All Known Implementing Classes:
MainRunnableImpl

public interface MainRunnable<T>
extends ThrowingRunnable

Interface passed to the InterleavedRunner that represents the main thread of execution.

Author:
alasdair.mackintosh@gmail.com (Alasdair Mackintosh)
See Also:
InterleavedRunner, SecondaryRunnable

Method Summary
 Class<T> getClassUnderTest()
          Returns the class being tested by this runnable.
 T getMainObject()
          Gets the main object being tested.
 Method getMethod()
          Gets the method being tested by this runnable.
 String getMethodName()
          Gets the name of the method being tested by this runnable.
 void initialize()
          Invoked by the framework before running this runnable.
 void terminate()
          Invoked by the framework after running this runnable.
 
Methods inherited from interface com.google.testing.threadtester.ThrowingRunnable
run
 

Method Detail

getClassUnderTest

Class<T> getClassUnderTest()
Returns the class being tested by this runnable. The class should be instrumented. If this runnable is not testing an instrumented class, then this method may return null.

See Also:
ClassInstrumentation, Instrumentation

getMethodName

String getMethodName()
Gets the name of the method being tested by this runnable. The runnable is expected to call this method during its own Runnable.run() method. If this runnable is not testing an instrumented class, then this method may return null. May return null if getMethod() does not.


getMethod

Method getMethod()
                 throws NoSuchMethodException
Gets the method being tested by this runnable. The runnable is expected to call this method during its own Thread.run() method. If this runnable is not testing an instrumented class, then this method may return null.

May throw a NoSuchMethodException if the method cannot be found. This will cause the InterleavedRunner to throw an IllegalArgumentException. May return null if getMethodName() does not.

Throws:
NoSuchMethodException

initialize

void initialize()
                throws Exception
Invoked by the framework before running this runnable. This method will be called once at the start of each iteration. Any object creation or initialization code can be placed here. Any exceptions thrown will be passed back to the caller of InterleavedRunner.interleave(M, com.google.testing.threadtester.SecondaryRunnable).

Throws:
Exception

getMainObject

T getMainObject()
Gets the main object being tested. The runnable is expected to invoke the test method (see getMethod() on this object. This method will not be called until initialize() has been called. Typical implementations will create a new instance of the test object in initialize(), and return it here.

See Also:
SecondaryRunnable.initialize(M)

terminate

void terminate()
               throws Exception
Invoked by the framework after running this runnable. Any test verification code can be placed here. Note that any exceptions thrown will be passed back to the caller of InterleavedRunner.interleave(M, com.google.testing.threadtester.SecondaryRunnable).

Throws:
Exception
See Also:
RunResult


Copyright © 2013. All Rights Reserved.