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
Check unit tests results
run_tradefed_tests.sh, the unit tests are exercising all parts of
the test harness including some error conditions. It will print verbose output
to the console, including stack traces.
The final summary of the results will indicate if a failure occured or not.
Example final summary in the console:
12:55:02 ========== Result Summary ========== Results summary for test-tag 'TFUnitTests': 3355 Tests [3355 Passed]
All tests are maintained to pass, so if any failure occurs on your local change please ensure the tests are fixed.
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.