- Used language is Python
- Tests are written from the end-user point of view.
- Tests should cover the UI interactions and features from end-user point of view.
- Example: Tap a button and something appears. Cause and effect.
- Template can be found from Qt Creator application wizard.
For information on executing testcases on a device, https://wiki.ubuntu.com/Touch/Testing/Autopilot/TestRunners.
Getting started with autopilot
Please read the official documentation above prior to attempting to run the examples.
Run some examples
In order to run some examples, you'll need to setup your pc and phablet device. Your pc should already have the phablet-tools installed. But if not, do so now.
1 sudo apt-get install phablet-tools
Next, run the following commands to setup a tunnel to ssh into the phablet device and install autopilot and the example tests.
From this point onwards, your shell is operating on the phablet device. Let's install autopilot. NOTE: The sudo password for the phablet device is "phablet".
1 sudo apt-get install autopilot-touch
Now, install some of the existing apps tests and run them.
1 sudo apt-get install camera-app-autopilot indicators-client-autopilot share-app-autopilot mediaplayer-app-autopilot qml-phone-shell-autopilot notes-app-autopilot gallery-app-autopilot phone-app-autopilot webbrowser-app-autopilot ubuntu-ui-toolkit-autopilot
Example packages and their commands to run the tests are:
1 autopilot3 run webbrowser_app
1 autopilot3 run camera_app
Tests can be written either in python 2 or python 3. For python 3 tests use "autopilot3", for python 2 ones use "autopilot".
To see what test cases a test suite has, and selectively run only some of them, use "autopilot list test_suite" where test_suite is one of the above examples. This will print a list with some entries, all starting with the test_suite's name. Copy/Paste the whole string to choose only this test:
1 autopilot3 run camera_app.tests.test_capture.TestCapture.test_record_video
Globally installed and local tests
Tests can be installed globally in /usr/lib/python3/dist-packages/ (like the ones in the previous step) or locally. Usually, when you develop tests you want to run them locally instead of installing them all the time. Checkout the code of one of those examples and you will find the following directory in there:
The "app_name" defines the name of the test suite. As this is standard python import stuff, we have to use underscores instead of dashes here.
To run a globally installed test suite, just execute "autopilot run test_suite" from some random directory. To run a local test suite cd to tests/autopilot/. You should see the test suite's name as a directory. Just call "autopilot run test_suite" in here to execute the local one. If a test suite is installed in your system AND can be found in your current working directory, the local one will be given preference.