com.google.testing.threadtester
Interface SecondaryRunnable<T,M extends MainRunnable<T>>

Type Parameters:
T - the type under test. It is expected that the runnable will invoke a method on this class.
M - the typed MainRunnable corresponding to this secondary runnable.
All Superinterfaces:
ThrowingRunnable
All Known Implementing Classes:
SecondaryRunnableImpl

public interface SecondaryRunnable<T,M extends MainRunnable<T>>
extends ThrowingRunnable

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

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

Method Summary
 boolean canBlock()
          Determines whether this runnable is allowed to block during the test.
 void initialize(M main)
          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

initialize

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

Throws:
Exception

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

canBlock

boolean canBlock()
Determines whether this runnable is allowed to block during the test. On many tests, the secondary runnable can be blocked if the main runnable is in a synchronized section of code. This is normally the desired behaviour, and the InterleavedRunner will handle this. However, if this method returns false, then the secondary is expected to run to completion without blocking, and the InterleavedRunner will throw an exception if the secondary blocks.



Copyright © 2013. All Rights Reserved.