Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
framework/ | 22-Nov-2023 | - | 19,844 | 15,363 | ||
tests/ | 22-Nov-2023 | - | 42,592 | 35,082 | ||
.gitignore | D | 22-Nov-2023 | 807 | 67 | 55 | |
README.md | D | 22-Nov-2023 | 4.9 KiB | 144 | 126 |
README.md
1# Android Comms Test Suite 2ACTS is a python-based test framework that is designed to be lightweight, 3pluggable, and easy to use. It initializes equipment and services associated 4to a test run, provides those resources to test classes, executes test cases, 5and generates test reports. 6 7ACTS follows the Google Open-source 8[Python Style Guide](https://google.github.io/styleguide/pyguide.html), and 9it is recommended for all new test cases. 10 11## ACTS Execution Flow Overview 12Below is a high level view of the ACTS flow: 131. Read configuration files 142. Create controllers 153. Sequentially execute test classes 16``` 17FooTest.setup_class() 18FooTest.setup_test() 19FooTest.test_A() 20FooTest.teardown_test() 21FooTest.setup_test() 22FooTest.test_B() 23FooTest.teardown_test() 24.... 25FooTest.teardown_class() 26BarTest.setup_class() 27.... 28``` 294. Destroy controllers 30 31## Preparing an Android Device 32### Allow USB Debugging 33USB debugging must be enabled before a device can take commands from adb. 34To enable USB debugging, first enable developer mode. 351. Go to Settings->About phone 362. Tap Build number repeatedly until "You're a developer now" is displayed. 37 38In developer mode: 391. Plug the device into a computer (host) 402. Run `$adb devices` 41- A pop-up asking to allow the host to access the android device may be 42displayed. Check the "Always" box and click "Yes". 43 44## ACTS Setup 451. ACTS requires three python dependencies: 46- Python3.4 47- The setuptools package 48- The pyserial package 492. From the ACTS directory, run setup 50- `$ sudo python3 setup.py develop` 51 52After installation, `act.py` and `flashutil.py` will be in usr/bin and can be 53called as command line utilities. Components in ACTS are importable under the 54package "acts." in Python3.4, for example: 55``` 56$ python3 57>>> from acts.controllers import android_device 58>>> device_list = android_device.get_all_instances() 59``` 60 61## Verifying Setup 62To verify the host and device are ready, from the frameworks folder run: 63- `$ act.py -c sample_config.json -tb SampleTestBed -tc SampleTest` 64 65If the above command executed successfully, the ouput should look something 66similar to following: 67``` 68[SampleTestBed] 07-22 15:23:50.323 INFO ==========> SampleTest <========== 69[SampleTestBed] 07-22 15:23:50.327 INFO [Test Case] test_make_toast 70[SampleTestBed] 07-22 15:23:50.334 INFO [Test Case] test_make_toast PASS 71[SampleTestBed] 07-22 15:23:50.338 INFO Summary for test class SampleTest: 72Requested 1, Executed 1, Passed 1, Failed 0, Skipped 0 73[SampleTestBed] 07-22 15:23:50.338 INFO Summary for test run 74SampleTestBed@07-22-2015_1-23-44-096: Requested 1, Executed 1, Passed 1, 75Failed 0, Skipped 0 76``` 77By default, all logs are saved in `/tmp/logs` 78 79## Breaking Down the Example 80Below are the components of the command run for the SampleTest: 81- `acts.py`: is the script that runs the test 82- -c sample_config: is the flag and name of the configuration file to be used 83in the test 84- -tb StampleTestBed: is the flag and name of the test bed to be used 85- -tc SampleTest: is the name of the test case 86 87### Configuration Files 88To run tests, required information must be provided via a json-formatted 89text file. The required information includes a list of “testbed” configs. 90Each specifies the hardware, services, the path to the logs directory, and 91a list of paths where the python test case files are located. Below are the 92contents of a sample configuration file: 93``` 94{ "_description": "This is an example skeleton test configuration file.", 95 "testbed": 96 [ 97 { 98 "_description": "Sample testbed with no devices", 99 "name": "SampleTestBed" 100 } 101 ], 102 "logpath": "/tmp/logs", 103 "testpaths": ["../tests/sample"], 104 "custom_param1": {"favorite_food": "Icecream!"} 105} 106``` 107 108### Test Class 109Test classes are instantiated with a dictionary of “controllers”. The 110controllers dictionary contains all resources provided to the test class 111and are created based on the provided configuration file. 112 113Test classes must also contain an iterable member self.tests that lists the 114test case names within the class. More on this is discussed after the following 115code snippet. 116``` 117from acts.base_test import BaseTestClass 118 119class SampleTest(BaseTestClass): 120 121 def __init__(self, controllers): 122 BaseTestClass.__init__(self, controllers) 123 self.tests = ( 124 "test_make_toast", 125 ) 126 127 """Tests""" 128 def test_make_toast(self): 129 for ad in self.android_devices: 130 ad.droid.makeToast("Hello World.") 131 return True 132``` 133By default all test cases listed in a Test Class\'s self.tests will be run. 134Using the syntax below will override the default behavior by executing only 135specific tests within a test class. 136 137The following will run a single test, test_make_toast: 138`$ act.py -c sample_config.txt -tb SampleTestBed -tc SampleTest:test_make_toast` 139 140Multiple tests may be specified with a comma-delimited list. The following 141will execute test_make_toast and test_make_bagel: 142- `$ act.py -c sample_config.txt -tb SampleTestBed -tc 143SampleTest:test_make_toast,test_make_bagel` 144