Contexts

A Context allows you to specify a set of conditions that are necessary for executing a given scenario.

You may often want to bring your application to a certain state before executing the scenario. You may also wish to bring your application to some state after the execution of a scenario. Further, these activities may be common across multiple scenarios. Expressing these activities as workflow steps clutter the scenarios and makes it difficult to understand their intent. A Context abstracts these activities as logical steps that need to be executed before and after a scenario execution.
A Context has two parts:
  • A setUp part which is executed before executing the scenario.
  • A teardown part which gets executed after the execution of the scenario.

Contexts, thus help keep the Scenario focused on what it is trying to test. Contexts can be reused across Scenarios. A scenario can have more than one Contexts.

For example, if you are testing a GUI based application that requires a person to login first, the login process can be abstracted as a Context

The 'Context' in Twist works similar to the setUp/tearDown in JUnit.

More on Context