org.testatoo.config.lifecycle
Interface LifeCycleConfig


public interface LifeCycleConfig

This configuration class enables you to hook into Testatoo system if you need to execute some code before, after all tests and also before, after each test and decide where you want to execute a givne test or not.


Method Summary
 LifeCycleConfig onStart(java.lang.Runnable runnable)
          Add an execution block to run after Testatoo system as started.
 LifeCycleConfig onStop(java.lang.Runnable runnable)
          Add an execution block to run before Testatoo system stops.
 LifeCycleConfig onTest(org.aopalliance.intercept.MethodInterceptor interceptor)
          Replace current MethodInterceptor used to intercept all test calls.
 LifeCycleConfig onTest(TestListener listener)
          Register a listener when a test method starts
 

Method Detail

onStart

LifeCycleConfig onStart(java.lang.Runnable runnable)
Add an execution block to run after Testatoo system as started. I.e. if you need to setup a database

Parameters:
runnable - The code to execute
Returns:
this

onStop

LifeCycleConfig onStop(java.lang.Runnable runnable)
Add an execution block to run before Testatoo system stops. I.e. if you need to clean a database

Parameters:
runnable - The code to execute
Returns:
this

onTest

LifeCycleConfig onTest(org.aopalliance.intercept.MethodInterceptor interceptor)
Replace current MethodInterceptor used to intercept all test calls. By default, no interceptor is setup and all test are executed.

You can setup an interceptor if you need to execute some code before or after a test, or if you need to skip a specifc test in some conditions.

Example:

protected void configure() {
     lifecycle()
         .onTest(new MethodInterceptor() {
             public Object invoke(MethodInvocation invocation) throws Throwable {
                 if (!invocation.getMethod().getName().equals("test3")) {
                        System.out.println("====> Running: " + invocation.getMethod());
                        return invocation.proceed();
                    } else {
                        System.out.println("====> Skipping: " + invocation.getMethod());
                        return null;
                    }
             }
         });
 }

Parameters:
interceptor - The interceptor to setup
Returns:
this

onTest

LifeCycleConfig onTest(TestListener listener)
Register a listener when a test method starts

Parameters:
listener - The listener to add
Returns:
this


Copyright © 2008-2010 Ovea. All Rights Reserved.