<> ||<>|| = Autopilot Testing = == Functional tests == * Used language is Python * Used framework is [[https://launchpad.net/autopilot|Autopilot]], which has a [[https://launchpad.net/autopilot-qt|Qt binding for Autopilot]] * 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. === Documentation === * [[https://developer.ubuntu.com/api/autopilot/python/1.5.0/guides-installation/|How to install]] * [[https://developer.ubuntu.com/api/autopilot/python/1.5.0/tutorial-getting_started/|Official Tutorial]] * [[https://developer.ubuntu.com/api/autopilot/python/1.5.0/|API Documentation]] * [[https://developer.ubuntu.com/api/autopilot/python/1.5.0/guides-running_ap/#visualise-introspection-tree|Using vis for introspection]] * [[https://developer.ubuntu.com/api/autopilot/python/1.5.0/guides-running_ap/|How to run tests]] '''For information on executing testcases on a device, [[https://wiki.ubuntu.com/Touch/Testing/Autopilot/TestRunners||see this page]].''' == 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. {{{#!highlight bash 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. {{{#!highlight bash phablet-shell }}} 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".'' {{{#!highlight bash sudo apt-get install autopilot-touch }}} Now, install some of the existing apps tests and run them. {{{#!highlight bash 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: * webbrowser-app-autopilot: {{{#!highlight bash autopilot3 run webbrowser_app }}} * camera-app-autopilot: {{{#!highlight bash 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: {{{#!highlight bash 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: {{{#!highlight bash tests/autopilot/app_name/ }}} 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.