Target preparers are invoked before the tests in the test level in which they are defined. This allows the setup of any device for tests to run smoothly.
The base interface is
which allows implementation of a
setUp method to be executed. We
recommend implementing our basic abstract class
which provides a built-in disablement feature to easily disable a preparer.
The natural extension of
tearDown and is provided by a different
ITargetCleaner. That provides the
that allows cleaning up anything that was done in
setUp after the test
BaseTargetPreparer class also extends
We recommend each preparer be limited to a single main function, for example installing an APK or running a command. This allows for easier reuse of preparers.
Also check the list of available preparers before adding a new one to
avoid duplicating work. Preparers are available in
The object tag is
target_preparer, for example:
<target_preparer class="com.android.tradefed.targetprep.InstallApkSetup"> <option name="install-arg" value="-d"/> </target_preparer>
Also refer to Set up suites for context.
If specified in a top-level setup, the preparer runs only once for each
device. An example is
which is a top-level setup for Android Compatibility Test Suite (CTS) tests.
If specified at the module level, the preparer always runs before that
module. An example is
which defines how Tradefed runs the
backup CTS module.
Note that while the preparer runs before the module, it runs after any system status checkers.