This section explains how to run Trade Federation tests after making a change to the project. This includes:
- Where to add the new unit test classes
- Running unit tests in Eclipse and outside the Eclipse IDE
- Running the functional tests
- Running some of TF presubmit validation locally
Add unit tests
In the Android Open Source Project (AOSP), add the unit tests class in: tools/tradefederation/core/tests/src/com/android/tradefed/UnitTests.java
IMPORTANT: Adding your new unit test classes to these locations will result in them automatically running in presubmit without additional setup.
Run unit tests
All the AOSP unit tests and functional tests for Trade Federation are located in
Inside Eclipse, to run an individual unit test, simply right-click the test and select Run As > JUnit. To run all unit tests, run the com.android.tradefed.UnitTests suite.
You can also start the unit test from the command line in the Tradefed source
tree after building, like so:
Unit tests can be executed standalone, but functional tests should be executed
by using Trade Federation itself; they require an Android device. All functional
tests should follow the naming convention
Run functional tests
To run a functional test from Eclipse:
- Ensure a device is connected to the host and that
adband if necessary
fastbootare in Eclipse's PATH. The easiest way to do this is to launch Eclipse from a shell setup with the proper PATH.
- Create a Java application. Run configuration via Run > Run configurations.
- Set project to
google-tradefederation-testsand the main class to
- Provide the following command line arguments in the Arguments tab:
host --class <full path of test class to run>
- Click Run.
To run functional tests outside Eclipse.
- Build Trade Federation.
- Connect an Android device to the host.
- Optionally, choose the device by appending
--serial <serial no>as it appears in the output of
Running TF presubmit tests against local changes
If you want to run in a similar way as the TF presubmit, use this:
This will trigger all the TF presubmit tests against your locally built TF to help you validate that your change is not breaking any tests.
TF presubmit tests are a superset of the unit tests above, but it is slower to run them. So it is recommended to run the unit tests during development for quicker validation and to run the presubmits before uploading the CL.