352
edits
(adding TBD's) |
(reorder) |
||
| Line 12: | Line 12: | ||
* [http://www.cheat-sheets.org/saved-copy/Locators_table_1_0_2.pdf Locator Cheat Sheet] | * [http://www.cheat-sheets.org/saved-copy/Locators_table_1_0_2.pdf Locator Cheat Sheet] | ||
= | = Tests - Style = | ||
== Naming == | |||
* Module names should be called test_ and then behavioral areas. | |||
test_search.py | |||
* Test method names should always show the intent of the test case. | |||
<source lang="python"> | |||
# Good | |||
def test_that_advanced_search_does_not_find_item(self): | |||
# Bad | |||
def test_advanced_search(self): | |||
</source> | |||
== File Headers == | == File Headers == | ||
| Line 72: | Line 85: | ||
</source> | </source> | ||
== Actions == | |||
* Methods that perform actions on the page should indicate the action in the method name. | |||
<source lang="python"> | |||
# Good | |||
def click_report_with_length(length) | |||
# Bad | |||
def report_length(length) | |||
</source> | |||
* Actions should wait for the appropriate action to complete. This could be an implicit or explicit wait. For example, clicking a login button might explicitly wait for a username field to be visible. | |||
== Use testvars.json == | |||
TBD - njpark | |||
== Using high-level methods == | |||
TBD - jlorenzo | |||
* In a test, make sure to only have steps that are high level (for instance: messages.send_an_sms_to_yourself() instead of detailing every single tap and click) | |||
== Avoid sleep() calls == | |||
TBD - njpark | |||
== Variable naming == | |||
TBD - jlorenzo | |||
* Name your variables with units. For example: timeout_in_seconds, width_in_pixels | |||
* Don't shorten variable names. A bad example: self.t_out_err_tim = 1000 instead of self.time_out_error_time | |||
== app.py and regions/helper.py == | |||
TBD - njpark | |||
== How to create filename strings == | |||
TBD - njpark | |||
http://mxr.mozilla.org/gaia/source/tests/python/gaia-ui-tests/gaiatest/apps/settings/app.py#296 | |||
== Meaningful custom Assert() messages == | |||
TBD - njpark | |||
https://bugzilla.mozilla.org/show_bug.cgi?id=1198449#c2 | |||
== Clean up afterwards == | |||
TBD - njpark | |||
== Avoid code duplication == | |||
TBD - jlorenzo | |||
* Use parameterized() | |||
* Centralize workarounds | |||
== Simulate end-user check == | |||
TBD - jlorenzo | |||
* Check what an end-user would check. | |||
== Making test multi-locale == | |||
TBD - njpark | |||
* we check the raw text in order to verify the input from the user (for instance a phone number put in the dialer, we verify it appears in the call log) | |||
* we test the l10n-id for any string that comes from Gaia only (like an error message) | |||
== Be aware of outside consumers of ui-test == | |||
TBD - mwargers | |||
* Be aware if you change the Gaia UI test API, that outside consumers (mtbf, etc) might get broken | |||
= Logic = | |||
== Handling shadow DOM == | |||
TBD - njpark | |||
== Switching frames and system frame == | |||
TBD - mwargers | |||
== Handling browser instances == | |||
TBD - mwargers | |||
== Returning the page object after completing an action == | |||
TBD - njpark | |||
When writing methods that is doing some action on the device, for instance opening an app or opening a subpage, make sure that the resulting action is finished and return the object of the resulting action, e.g. the app or the subpage (PageRegion) | |||
= Use of Libraries = | |||
== Page Objects == | == Page Objects == | ||
TBD - jlorenzo | TBD - jlorenzo | ||
| Line 136: | Line 212: | ||
</source> | </source> | ||
== | == PageRegions == | ||
TBD - jlorenzo | TBD - jlorenzo | ||
* How to deal with stale root_elements | * How to deal with stale root_elements | ||
| Line 177: | Line 240: | ||
Another example where this might be used is on a search results page, the page region being the search results element. | Another example where this might be used is on a search results page, the page region being the search results element. | ||
== Assertions == | == Assertions == | ||
| Line 206: | Line 255: | ||
assert a == 'expected result' | assert a == 'expected result' | ||
</source> | </source> | ||
== How to use GaiaHeader and GaiaBinaryControl == | == How to use GaiaHeader and GaiaBinaryControl == | ||
TBD - jlorenzo | TBD - jlorenzo | ||
= Submitting and Reviewing Patches = | = Submitting and Reviewing Patches = | ||
edits