Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Run instrumentation tests from existing APKs
Stay organized with collections
Save and categorize content based on your preferences.
These instructions assume you have the Trade Federation package available
locally; if not,
follow the download instructions
to obtain it.
Then use the following command to install the APK of instrumentation tests,
execute the tests, and display the tests that are running:
./tradefed.sh run instrumentations --apk-path <path of your apk>
With output resembling:
07-17 10:55:32 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testOfArgb
07-17 10:55:33 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testIsRunning
07-17 10:55:34 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testGetCurrentPlayTime
07-17 10:55:35 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testStartDelay
07-17 10:55:35 I/InvocationToJUnitResultForwarder: Run ended in 2m 20s
You can optionally specify --serial <device serial number>
to run
against a given device. The serial number of your device can be obtained
using adb devices
.
See the
Testing through Tradefed section
for more details about Tradefed executions.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[],[],null,["# Run instrumentation tests from existing APKs\n\nThese instructions assume you have the Trade Federation package available\nlocally; if not,\n[follow the download instructions](/docs/core/tests/tradefed/fundamentals/machine_setup#download-tradefed)\nto obtain it.\n\nThen use the following command to install the APK of instrumentation tests,\nexecute the tests, and display the tests that are running: \n\n ./tradefed.sh run instrumentations --apk-path \u003cpath of your apk\u003e\n\nWith output resembling: \n\n 07-17 10:55:32 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testOfArgb\n 07-17 10:55:33 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testIsRunning\n 07-17 10:55:34 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testGetCurrentPlayTime\n 07-17 10:55:35 D/InvocationToJUnitResultForwarder: Starting test: android.animation.cts.ValueAnimatorTest#testStartDelay\n 07-17 10:55:35 I/InvocationToJUnitResultForwarder: Run ended in 2m 20s\n\nYou can optionally specify `--serial \u003cdevice serial number\u003e` to run\nagainst a given device. The serial number of your device can be obtained\nusing `adb devices`.\n\nSee the\n[Testing through Tradefed section](/docs/core/tests/tradefed/testing/through-tf)\nfor more details about Tradefed executions."]]