Using Test Suites

We have so far created a test to open https://www.google.com and to search for given terms. We could keep adding steps to this one test but doing so will eventually be impractical.

One test per user journey is more manageable and easier to maintain. This will lead to a collection of tests covering a range of pages, functionality and user journeys. Tests will vary in their level of critical importance.

A test suite brings together a collection of tests grouped in a manner that fits your needs. A given test can be present in any number of test suites.

You might want to group tests by priority, examining first the most critical user journeys as grouped in one suite and then examining afterwards some lower-priority functionality grouped in further test suites.

Let’s see how this works by creating some more tests for Google.

Additional Google Tests

Google has a store where you can buy devices and accessories. The page at https://about.google presents an overview of the company. Let’s create some tests for those.

# examples/test/google-store.yml
config:
  browsers:
    - chrome
  url: https://store.google.com

"verify Google Store is open":
  assertions:
    - $page.url is "https://store.google.com"
    - $page.title matches "/^Google Store/"

"top navigation elements are present":
  assertions:
    - $"div[new-product-nav]" exists
    - $"div[new-product-nav] button[data-category-id='phones']" exists
    - $"div[new-product-nav] button[data-category-id='connected_home']" exists
    - $"div[new-product-nav] button[data-category-id='tablets']" exists
    - $"div[new-product-nav] button[data-category-id='laptops']" exists
    - $"div[new-product-nav] button[data-category-id='accessories']" exists
    - $"div[new-product-nav] a[href='/collection/offers']" exists
# examples/test/about-google.yml
config:
  browsers:
    - chrome
  url: https://about.google/

"verify about.google is open":
  assertions:
    - $page.url is $config.url
    - $page.title is "About | Google"

"top navigation elements are present":
  assertions:
    - $"nav .top-nav" exists
    - $"nav .top-nav a[href='./']" exists
    - $"nav .top-nav a[href='./google-in-uk/']" exists
    - $"nav .top-nav a[href='./products/']" exists
    - $"nav .top-nav a[href='./commitments/']" exists
    - $"nav .top-nav a[href='./stories/']" exists

Creating Test Suites

A test suite is a YAML list. It doesn’t get much easier than this.

Create a YAML document for your test suite and within define a list of imports. The first test imported is the first to be run and so on.

# examples/test-suite/google-high-priority.yml

- "../test/google-search-query-literal.yml"
- "../test/google-store.yml"
# examples/test-suite/google-low-priority.yml

- "../test/about-google.yml"