Overview

Documents the approach to functional/integration testing for the GUI itself using Selenium.  

NOTE: integration testing is only minimally implemented, this mostly presents the methodology and approach that would be used to fully flesh out the automated GUI integration tests.

Coverage

There are General application features, a variety of dashboards, and widgets that can go on the various dashboards.  For example,

Complete coverage would address each mode of use of general features and each widget that appears on  each dashboard.

Coverage Definition

The attached spreadsheet formally defines automated GUI QA coverage from an integration testing perspective. 

Assumptions

Coverage is defined in a multi-dimensional matrix that takes into account the services, the methods of the services, and the modes of use of the services (including normal use, degerate use, and edge cases).  Coverage also considers combinations of calls that have related effects to each other and a placeholder for "ad hoc" tests that can be filled in as gaps in coverage are identified.

The following sample coverage spreadsheet begins to outline the methodology for defining coverage though it is not fully fleshed out.

Organization

Integration tests are organized under the integration-testing project.  Looking through the Java packages, you should find a "org.ihtsdo.otf.mapping.test.selenium" package that defines a number of test classes that represent the coverage spreadsheet.

Each column of each tab of the coverage spreadsheet is represented by a single testing class, where each row within that column corresponds to a particular method of that testing class.  The coverage spreadsheet defines both the class names used to implement tests as well as the method names (so they can be easily cross referenced).

The test names themselves are "test cases" that are organized into "test suites" according to the structure of the spreadsheet.

For each test suite and test case, there should also exist documentation.  A test suite is a collection of test cases and a test case is a "script" detailing the actions involved and the expected outcomes with any other needed information.

Integration Test Suites

Test suites are organized by spreadsheet tab.

Implementation Using Selenium

Automated GUI testing is accomplished via Selenium in the integration-tests package.  Selenium enables automated interaction with HTML DOM objects, including form completion and submission, button clicking, and element search.

To properly interact with the application, elements should be assigned unique identifiers in the application.  This is not comprehensively done across the application yet.  As test cases are developed, identifiers should be assigned to elements that need them to complete the test. While selenium supports identifying elements by means other than id, it is strongly recommended that only the ID mechanism be used.  It is more stable across time and continued development of the application.

Requirements

The following conditions are required for Selenium automated GUI testing to function

Configuration Parameters

The integration test is run with a -Drun.config parameter pointing to a config file that contains the following configuration properties.

For example:

#
# Selenium UI testing parameters
#                      
selenium.browser = firefox                                
selenium.timeout = 10000
selenium.user.guest.name = guest
selenium.user.valid.name = EDIT_THIS
selenium.user.valid.password = EDIT_THIS
selenium.user.invalid.name = not_a_real_user

 

Selenium Interaction with AngularJS

AngularJS and Selenium are not natively compatible.  Specifically, Selenium does not by default wait for dynamic DOM manipulation by Angular.

Two sections of code are displayed in the code block below:

// THIS WORKS
(new WebDriverWait(webDriver, new Long(
        config.getProperty("selenium.timeout")) / 1000))
        .until(new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
            return webDriver.findElement(By.id("[ELEMENT NAME"])).getText()
                .length() > 0;
          }
        });
 
// THIS DOES NOT WORK
(new WebDriverWait(webDriver, new Long(
        config.getProperty("selenium.timeout")) / 1000))
        .until(new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
            return webDriver.findElement(By.id("[ELEMENT NAME"])).getText();
          }
        });

 

References/Links