Confirmed users
211
edits
(Updated example to reflect more Firefox OS) |
|||
Line 63: | Line 63: | ||
== General == | == General == | ||
* All page objects should inherit from <code> | * All page objects should inherit from <code>Base</code> in base.py. | ||
* Page objects should not do asserts. This should be done within the test. | * Page objects should not do asserts. This should be done within the test. | ||
* Each page should be grouped within one module. | * Each page should be grouped within one module. | ||
* If using multiple words to describe a module separate them with underscores '_' | * If using multiple words to describe a module separate them with underscores '_' | ||
* Single quotes (') should be used instead of double (") throughout. | * Single quotes (') should be used instead of double (") throughout. | ||
* Methods should have a single purpose. | * Methods should have a single purpose. | ||
Line 76: | Line 75: | ||
<source lang="python"> | <source lang="python"> | ||
# Good | # Good | ||
def | def open_login(self) | ||
self. | self.marionnette.find_element(*self._login_locator).tap() | ||
# Bad | # Bad | ||
def | def open_login(self) | ||
if not self.is_user_logged_in: | if not self.is_user_logged_in: | ||
self. | self.marionnette.find_element(*self._login_locator).tap() | ||
else: | else: | ||
pass | pass | ||
Line 141: | Line 140: | ||
<source lang="python"> | <source lang="python"> | ||
class | class MyApp(Page): | ||
@property | @property | ||
def header(self): | def header(self): | ||
return | return MyApp.HeaderRegion(self.marionette) | ||
class HeaderRegion(Page): | class HeaderRegion(Page): | ||
Line 151: | Line 150: | ||
_login_link = (By.ID, "home") | _login_link = (By.ID, "home") | ||
@def | @def tap_login(self): | ||
self. | self.marionette.find_element(*self._login_link).tap() | ||
</source> | </source> | ||
Line 165: | Line 164: | ||
* Module names should be called test_ and then behavioral areas. | * Module names should be called test_ and then behavioral areas. | ||
test_search.py | test_search.py | ||
* Test method names should always show the intent of the test case. | * Test method names should always show the intent of the test case. | ||
Line 175: | Line 169: | ||
<source lang="python"> | <source lang="python"> | ||
# Good | # Good | ||
def test_that_advanced_search_does_not_find_item(self | def test_that_advanced_search_does_not_find_item(self): | ||
# Bad | # Bad | ||
def test_advanced_search(self | def test_advanced_search(self): | ||
</source> | </source> | ||
Line 184: | Line 178: | ||
* Tests should handle the asserts -- not the page objects. | * Tests should handle the asserts -- not the page objects. | ||
* Tests should use | * Tests should use unittest's [https://docs.python.org/2/library/unittest.html#assert-methods assert methods]. | ||
= Size of patches = | = Size of patches = | ||
To make sure that we can review your patch as quickly and efficiently as possibly we would like patches to have a single test in them and the necessary changes to the page objects. This also limits the chances of merge conflicts later. | To make sure that we can review your patch as quickly and efficiently as possibly we would like patches to have a single test in them and the necessary changes to the page objects. This also limits the chances of merge conflicts later. | ||