We are currently working on fixing UI tests to follow guidelines, which are aimed to improve tests stability, readability and maintainability.
If you see that the test is not annotated with @Category(BuildTests.class) then it must be fixed. Please create a sub-task for
Getting issue details...
for the test that needs to be fixed. Modify the test to conform the following guidelines:
- Tests should be added under https://github.com/openmrs/openmrs-distro-referenceapplication/tree/master/ui-tests/src/test/java/org/openmrs/reference
- Tests and Pages should include the OpenMRS license at the beginning of the file.
- Each test class should be named starting with a verb, which best describes an action that is being tested, e.g. SearchActiveVisitsTest. By convention all test class names must end with Test.
- In general each class should contain one test method (annotated with @Test and @Category(BuildTests.class) and the test method should start with a verb and can provide a more detailed description of what is being tested than the class, e.g. searchActiveVisitsByPatientNameOrIdOrLastSeenTest. In rare cases we let test classes to have more than one test method.
- The test method should not visit more than 10 pages and should have 3-15 steps.
- You must not access Driver in a test. It is only allowed to perform actions calling methods in classes extending Page.
- It is not allowed to call Driver's methods in a page. You should be calling methods provided by the Page superclass.
- Each test class should start from homePage and extend ReferenceApplicationTestBase.
- It is not allowed to instantiate classes extending Page in test classes. They must be returned from Page's actions e.g. ActiveVisitsPage activeVisitsPage = homePage.goToActiveVisitsSearch();
- Do not store pages in class fields as it suggests they can be used for other tests.
- Each page should have a corresponding class, which extends Page and it should be added under https://github.com/openmrs/openmrs-distro-referenceapplication/tree/master/ui-tests/src/main/java/org/openmrs/reference/page
- The page class should be named after page's title and end with Page.
- Elements of the page must be found by id or class attributes. It is not allowed to find them by xpath expressions unless absolutely necessary. Locators must be defined as private (not public) static final fields of the class. See CSS Selectors.
For reference please use https://github.com/openmrs/openmrs-distro-referenceapplication/blob/master/ui-tests/src/test/java/org/openmrs/reference/SearchActiveVisitsTest.java and https://github.com/openmrs/openmrs-distro-referenceapplication/blob/master/ui-tests/src/main/java/org/openmrs/reference/page/ActiveVisitsPage.java
In case of questions, please write on talk.openmrs.org. The guidelines are work in progress and if you disagree, let's discuss. Send us a pull request with your changes and provide a link in the JIRA issue.