concordion / concordion-scope-examples

Demonstrates the usage of different field scopes in Concordion.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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. The tests use Selenium's ChromeDriver, so you'll need to have:

  1. Chrome installed (or you could change the code to use a different driver).
  2. chromedriver installed and added to the PATH (or the webdriver.chrome.driver system property set)

To run the project:

  1. checkout (or download and unzip) the relevant branch from below
  2. 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.

About

Demonstrates the usage of different field scopes in Concordion.

License:Other


Languages

Language:Shell 100.0%