Confirmed users
2,197
edits
Nalexander (talk | contribs) (Refer to robocop (rather than robotium) as much as possible.) |
(Removed reference to Robocop performance tests, which no longer exist.) |
||
| (21 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
== | == Introduction == | ||
Robocop provides UI-level testing for Firefox for Android. It is based on Google's [http://robotium.org/ Robotium] test automation framework for Android. | |||
Robocop uses Robotium to inject events into the Java front-end of Firefox for Android and to monitor and verify Firefox events and UI views. | |||
The source code for the Robocop harness, and the test source code, is maintained on mozilla-central in <tt>mobile/android/tests/browser/robocop</tt>. | |||
Robocop-based UI functionality tests are run with the mochitest test harness and appear on Treeherder under the symbol tc(rc). | |||
== Setup == | == Setup == | ||
=== Step one: Build Fennec === | |||
Follow the instructions at https://wiki.mozilla.org/Mobile/Fennec/Android#Building_Fennec to build, package, and install Fennec on your device. | |||
== Running tests == | == Running tests == | ||
==== | ==== Running all the tests ==== | ||
From the root directory: | |||
mach build mobile/android/tests/browser/robocop | |||
mach robocop | |||
Some notes for running tests: | |||
* Your device screen should be turned on — otherwise some tests may fail. | |||
* To run tests that load a page from the desktop host without timing out, both the test device and desktop host must be on the same network (e.g., device can't be on 3G). | |||
==== Running a single test ==== | ==== Running a single test ==== | ||
From the | From the root directory: | ||
<pre> | <pre>./mach robocop <test-name></pre> | ||
where <test-name> would be a test name such as "testLoad": | |||
<pre>./mach robocop testLoad</pre> | |||
See also https://wiki.mozilla.org/Mobile/Fennec/Android | See also https://wiki.mozilla.org/Mobile/Fennec/Android/Testing for advanced options. | ||
== Updating your test directory == | == Updating your test directory == | ||
It is not always necessary to rebuild Fennec to use new tests. If you are updating the build with your own test, ensure that your test has been added to the manifest in | |||
It is not always necessary to rebuild Fennec to use new tests. If you are updating the build with your own test, ensure that your test has been added to the manifest in <tt>mobile/android/tests/browser/robocop/robocop.ini</tt>. | |||
Otherwise, you can retrieve tests from the repository by executing: | Otherwise, you can retrieve tests from the repository by executing: | ||
hg pull | hg pull | ||
hg update | hg update | ||
Now you can build the robocop part of Fennec by executing: | Now you can build the robocop part of Fennec by executing: | ||
mach build mobile/android/tests/browser/robocop | |||
== Frequently found errors == | |||
If you do not see your specific error below, it can sometimes help to uninstall and reinstall. To do this (and run the tests): | |||
adb uninstall org.mozilla.roboexample.test | |||
mach build mobile/android/tests/browser/robocop | |||
mach robocop testLoad | |||
Infrequent Runtime Errors | ===Infrequent Runtime Errors=== | ||
Two have been known to occur: One, where Fennec freezes when loading a page, the other where the page loads, but has 0 content. These are worked around by restarting the test. | |||
== What happens when a test is run == | == What happens when a test is run == | ||
Our tests are run from the | Our tests are run from the runrobocop.py script, which relies on devicemanager and other scripts/tools in the harness directory. Here is what happens: | ||
* create a [[http://people.mozilla.org/~jmaher/robocop_profile.zip fresh profile]] and copy it to the device (/mnt/sdcard/tests/profile) | * create a [[http://people.mozilla.org/~jmaher/robocop_profile.zip fresh profile]] and copy it to the device (/mnt/sdcard/tests/profile) | ||
| Line 81: | Line 67: | ||
host=http://mochi.test:8888/tests # mochi.test is defined in the profile proxy auto config | host=http://mochi.test:8888/tests # mochi.test is defined in the profile proxy auto config | ||
rawhost=http://192.168.1.73:8888/tests # used for some tests | rawhost=http://192.168.1.73:8888/tests # used for some tests | ||
* for each test case, in [[https://wiki.mozilla.org/Auto-tools/Projects/Robocop/robocop_ini robocop.ini]] we launch fennec. Here is an example of the first test case testallpagesTab: | * for each test case, in [[https://wiki.mozilla.org/Auto-tools/Projects/Robocop/robocop_ini robocop.ini]] we launch fennec. Here is an example of the first test case testallpagesTab: | ||
am instrument -w -e deviceroot /mnt/sdcard/tests -e class org.mozilla.fennec.tests.testAllPagesTab org.mozilla.roboexample.test/org.mozilla.fennec.FennecInstrumentationTestRunner | am instrument -w -e deviceroot /mnt/sdcard/tests -e class org.mozilla.fennec.tests.testAllPagesTab org.mozilla.roboexample.test/org.mozilla.fennec.FennecInstrumentationTestRunner | ||
| Line 87: | Line 72: | ||
== Notes == | == Notes == | ||
*If you are writing tests for Robocop, see [[ | *If you are writing tests for Robocop, see [[Auto-tools/Projects/Robocop/WritingTests|Writing Tests]] for more general API information and [[Mobile/Fennec/Android/UITest|UITest]] for details on using the current testing framework | ||
*We are using [[https://wiki.mozilla.org/Fennec/NativeUI/Messages NativeUI Messages]] to talk between Robocop and gecko | *We are using [[https://wiki.mozilla.org/Fennec/NativeUI/Messages NativeUI Messages]] to talk between Robocop and gecko | ||
*There has been interest in using a record/replay tool similar to [[http://testdroid.com/testdroid/125/testdroid-recorder-100beta-out testdroid]]. Most likely this will allow for people to record something and then we can hand edit it into a proper test case. | *There has been interest in using a record/replay tool similar to [[http://testdroid.com/testdroid/125/testdroid-recorder-100beta-out testdroid]]. Most likely this will allow for people to record something and then we can hand edit it into a proper test case. | ||
*adb shell am instrument -w org.mozilla.roboexample.test/android.test.InstrumentationTestRunner | *adb shell am instrument -w org.mozilla.roboexample.test/android.test.InstrumentationTestRunner | ||
*Trevor's Presentation on it can be found in [[https://wiki.mozilla.org/File:Robocop_final_presentation.zip.gz This zip]] | *Trevor's Presentation on it can be found in [[https://wiki.mozilla.org/File:Robocop_final_presentation.zip.gz This zip]] | ||