A test decorator allows you to run some code before and after your test. With a test decorator, you can wrap a single test, an entire suite of tests, or another test decorator. Some examples of test decorators are measuring performance or setting up and cleaning up a database.
Create your test case by extending XDriveDecorator and overriding the constructor.
package com.flexiblewebsolutions.xdriveunit.extensions.test; import junit.framework.Test; import junit.framework.TestResult; import com.flexiblewebsolutions.xdriveunit.XDriveDecorator; public class Test1TestDecorator extends XDriveDecorator { public Test1TestDecorator( Test pTest, StringBuffer pParameterData ) { super( pTest, pParameterData ); } public void run( TestResult arg0 ) { System.err.println( "Before in Test1TestDecorator" ); super.run( arg0 ); System.err.println( "AFTER in Test1TestDecorator" ); } }
Your existing test config should be modified to include information for the decorator.
<test> <decorator> <decoratorclass>com.flexiblewebsolutions.xdriveunit.extensions.test.Test1TestDecorator</decoratorclass> <parameterdata></parameterdata> <test> <testmethod> <inputFileName></inputFileName> <testmethodname>testStuff</testmethodname> </testmethod> </test> </decorator> </test>