Demonstrates the usage of different field scopes in Concordion.
Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.utility
.gitignore
.travis.yml
LICENSE.txt
README.md

README.md

Concordion Scope Examples

Demonstrates the usage of different field scopes in Concordion.

With the introduction of examples running as separate JUnit tests in Concordion 2.0.0, Concordion reinitialises the fields in fixture objects for each Concordion example.

This encourages users to keep examples completely independent of each other, ensuring clean state per example and allowing individual examples to be run in isolation. It also makes the specification easier to follow when you can read examples in isolation.

However, we recognise that sometimes you will want to share fields across a specification when the field is expensive to initialise, for example a browser instance or database connection.

This project demonstrates the use of different scopes to share browsers across web tests.

The repository contains multiple branches, where each branch shows a different combination of field scope and runner (serial or parallel). The code includes the use of the ScreenshotExtension to demonstrate the use of extensions in different scopes.

The project uses Selenium Webdriver to run some browser tests. In order to run it, you'll need to have Firefox installed (or modify the code to use a different driver). Selenium WebDriver now requires you to download and unzip the Gecko driver and add it to your path (or set the webdriver.gecko.driver system property to the absolute path to the gecko driver executable).

To run the project using Firefox:

  1. Install Firefox (or modify the code to use a different driver)
  2. Download and unzip the Gecko driver and add it to your path (or set the webdriver.gecko.driver system property to the absolute path to the gecko driver executable).
  3. checkout (or download and unzip) the relevant branch from below
  4. run gradlew test

Suite Scope

The browser(s) are reused across all specifications, where the specifications are structured as a suite using the run command to invoke child specifications.

  • per_suite_serial (download) - a single browser instance is used across all tests.
  • per_suite_parallel (download) - initiates a single browser instance per thread across all tests. Note that the parallel runner does not guarantee that the same threads will be used across tests - additional threads may be started and old threads not reused.

Specification Scope

A browser is created and destroyed per specification, using Concordion field scoping.

Example Scope

A browser is created and destroyed per example. This is the default scope and ensures clean state for each browser instance.

Note that the parallel tests are using the ParallelRunExtension to run the specifications in parallel. Concordion does not currently support running the individual examples in parallel.

As an alternative the fixtures from Specification Scope above can easily be modified to example scope by changing the value of the @ConcordionScoped annotation:

Additional Method Hooks

In some cases, you may wish to use additional method hooks.

In per_spec_serial_with_example_hooks (download), a browser is created and destroyed per specification, with a (fake) login/logout triggered per example.