• Home
Name Date Size #Lines LOC

..--

framework/03-May-2024-21,60716,749

tests/03-May-2024-46,86638,223

.gitignoreD03-May-2024807 6755

README.mdD03-May-20245.3 KiB149131

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```
107The ***testpaths*** and ***logpath*** keys may alternately be supplied via the
108execution environment though the ACTS_TESTPATHS and ACTS_LOGPATH keys
109respectively. To specify multiple test paths, the key should follow
110standard a ':'-delimited format. Explicit keys in a configuration file will
111override any defaults provided by the environment.
112
113### Test Class
114Test classes are instantiated with a dictionary of “controllers”. The
115controllers dictionary contains all resources provided to the test class
116and are created based on the provided configuration file.
117
118Test classes must also contain an iterable member self.tests that lists the
119test case names within the class.  More on this is discussed after the following
120code snippet.
121```
122from acts.base_test import BaseTestClass
123
124class SampleTest(BaseTestClass):
125
126    def __init__(self, controllers):
127        BaseTestClass.__init__(self, controllers)
128        self.tests = (
129            "test_make_toast",
130        )
131
132    """Tests"""
133    def test_make_toast(self):
134        for ad in self.android_devices:
135            ad.droid.makeToast("Hello World.")
136        return True
137```
138By default all test cases listed in a Test Class\'s self.tests will be run.
139Using the syntax below will override the default behavior by executing only
140specific tests within a test class.
141
142The following will run a single test, test_make_toast:
143`$ act.py -c sample_config.txt -tb SampleTestBed -tc SampleTest:test_make_toast`
144
145Multiple tests may be specified with a comma-delimited list. The following
146will execute test_make_toast and test_make_bagel:
147- `$ act.py -c sample_config.txt -tb SampleTestBed -tc
148SampleTest:test_make_toast,test_make_bagel`
149