Jeremy Goldman | ce46d9b | 2020-10-21 02:21:54 +0000 | [diff] [blame] | 1 | The simplest way to run all SettingsUnitTests is with atest |
| 2 | $ atest SettingsUnitTests |
| 3 | |
| 4 | A single class can also be tested with the following command |
| 5 | $ atest -c <YourClassName> |
| 6 | |
Xinyi Zhou | 7871ccf | 2021-11-02 14:04:46 -0700 | [diff] [blame] | 7 | // The following instructions show how to run the test suite using make + adb // |
Jeremy Goldman | ce46d9b | 2020-10-21 02:21:54 +0000 | [diff] [blame] | 8 | |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 9 | To build the tests you can use the following command at the root of your android source tree |
Roozbeh Pournader | ad38934 | 2017-07-12 11:37:59 -0700 | [diff] [blame] | 10 | $ make -j SettingsUnitTests |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 11 | |
Jeremy Goldman | 6e6d785 | 2020-10-19 08:11:32 +0000 | [diff] [blame] | 12 | The test apk then needs to be installed onto your test device. The apk's location will vary |
| 13 | depending on your device model and architecture. At the end of the make command's output, there |
| 14 | should be a line similar to the following: |
Roozbeh Pournader | ad38934 | 2017-07-12 11:37:59 -0700 | [diff] [blame] | 15 | "Copy: ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk" |
Jeremy Goldman | 6e6d785 | 2020-10-19 08:11:32 +0000 | [diff] [blame] | 16 | Install via the following command: |
Roozbeh Pournader | ad38934 | 2017-07-12 11:37:59 -0700 | [diff] [blame] | 17 | $ adb install -r ${ANDROID_PRODUCT_OUT}/testcases/SettingsUnitTests/arm64/SettingsUnitTests.apk |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 18 | |
| 19 | To run all tests: |
Brett Chabot | 031dcf5 | 2018-12-13 19:06:32 -0800 | [diff] [blame] | 20 | $ adb shell am instrument -w com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 21 | |
| 22 | To run all tests in a specific class: |
Brett Chabot | 031dcf5 | 2018-12-13 19:06:32 -0800 | [diff] [blame] | 23 | $ adb shell am instrument -w -e class com.android.settings.<class> com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 24 | |
| 25 | To run a specific test: |
Brett Chabot | 031dcf5 | 2018-12-13 19:06:32 -0800 | [diff] [blame] | 26 | $ adb shell am instrument -w -e class com.android.settings.<class>#<test> com.android.settings.tests.unit/androidx.test.runner.AndroidJUnitRunner |
Benjamin Franz | d11b713 | 2016-01-21 12:27:36 +0000 | [diff] [blame] | 27 | |
| 28 | More general information can be found at |
| 29 | http://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner.html |