| 1 | Running Autopilot tests |
| 2 | ======================= |
| 3 | |
| 4 | NOTE: autopilot is currently not available in UBports and the instructions below are no longer accurate. |
| 5 | |
| 6 | The calculator app follows a test driven development where autopilot tests are run before every merge into trunk. If you are submitting your bugfix/patch to the calculator app, please follow the following steps below to ensure that all tests pass before proposing a merge request. |
| 7 | |
| 8 | If you are looking for more info about Autopilot or writing AP tests for the calculator app, here are some useful links to help you: |
| 9 | |
| 10 | - [Ubuntu - Quality](http://developer.ubuntu.com/start/quality) |
| 11 | - [Ubuntu - Autopilot](https://developer.ubuntu.com/api/autopilot/python/1.5.0/) |
| 12 | |
| 13 | For help and options on running tests, see: |
| 14 | |
| 15 | - [Autopilot Tests](https://developer.ubuntu.com/en/start/platform/guides/running-autopilot-tests/) |
| 16 | |
| 17 | Prerequisites |
| 18 | ============= |
| 19 | |
| 20 | Install the following autopilot packages required to run the tests, |
| 21 | |
| 22 | $ sudo apt-get install ubuntu-ui-toolkit-autopilot xserver-xephyr ratpoison xvfb |
| 23 | |
| 24 | Running tests on the desktop |
| 25 | ============================ |
| 26 | |
| 27 | Using terminal: |
| 28 | |
| 29 | * Branch the Calculator app code, for example, |
| 30 | |
| 31 | $ bzr branch lp:ubuntu-calculator-app |
| 32 | |
| 33 | * Navigate to the tests/autopilot directory. |
| 34 | |
| 35 | $ cd ubuntu-calculator-app/tests/autopilot |
| 36 | |
| 37 | * Run all tests. |
| 38 | |
| 39 | $ autopilot3 run -vv lomiri_calculator_app |
| 40 | |
| 41 | * To list all tests: |
| 42 | |
| 43 | $ autopilot3 list lomiri_calculator_app |
| 44 | |
| 45 | * To run only one test (for instance: lomiri_calculator_app.tests.test_main.MainTestCase.test_divide_by_zero) |
| 46 | |
| 47 | $ autopilot3 run -vv lomiri_calculator_app.tests.test_main.MainTestCase.test_divide_by_zero |
| 48 | |
| 49 | * Debugging tests using autopilot vis |
| 50 | |
| 51 | $ autopilot3 launch -i Qt qmlscene app/ubuntu-calculator-app.qml |
| 52 | |
| 53 | $ autopilot3 vis |
| 54 | |
| 55 | Running tests using Ubuntu SDK |
| 56 | ============================== |
| 57 | |
| 58 | Refer this [tutorial](https://developer.ubuntu.com/en/start/platform/guides/running-autopilot-tests/) to run tests on Ubuntu SDK: |
| 59 | |
| 60 | Running tests within virtual environment |
| 61 | ======================================== |
| 62 | |
| 63 | Warning: Running virtual environment is not working with proprietary NVidia drivers. |
| 64 | |
| 65 | To run all tests from sandbox, run following command from tests/autopilot: |
| 66 | |
| 67 | $ autopilot3-sandbox-run -X —windowmanager ratpoison -s 400x600x24 lomiri_calculator_app/ |
| 68 | |
| 69 | Running tests on device or emulator: |
| 70 | ==================================== |
| 71 | |
| 72 | Using autopkg: |
| 73 | |
| 74 | * Branch the Calculator app code, for example, |
| 75 | |
| 76 | $ bzr branch lp:ubuntu-calculator-app |
| 77 | |
| 78 | * Navigate to the source directory. |
| 79 | |
| 80 | $ cd ubuntu-calculator-app |
| 81 | |
| 82 | * Build a click package |
| 83 | |
| 84 | $ click-buddy . |
| 85 | |
| 86 | * Run the tests on device (assumes only one click package in the directory) |
| 87 | |
| 88 | $ adt-run . *.click --- ssh -s adb -- -p <PASSWORD> |
| 89 |