A test resource is a component that must be available during a scenario and cleaned up afterward. An application host and a simulated payment gateway are both test resources. Starting the gateway for every scenario works, but wastes time when only a few scenarios need it. section 16.1
For a scenario-lifetime resource, a before-scenario hook can start it and an after-scenario hook can stop it. Tagging only the scenarios that need the gateway keeps those hooks selective. If the application host needs the gateway at startup, specify hook order so the gateway starts first. section 16.1
Table 16.1 Resource usages and tagging strategies
|
Resource
usage
|
Tagging
strategy
|
Tag
expression
|
|
Needed for all scenarios
|
No tags needed
|
n/a
|
|
Needed by a few scenarios
|
Tag scenarios that need the resource
|
@payment_gateway
|
|
Needed by most scenarios
|
Tag scenarios that do not need the
resource
|
not
@no_payment_gateway
|
|
A set of scenarios needs the
resource, but each needs a different variation or configuration
|
Tag the scenarios with tags following
a fixed format (e.g., @payment_gateway:<name>): @payment_gateway:stripe, @payment_gateway:paypal
|
Do not pass the tag expression to the
hook attribute, but use the API of the scenario automation tool in the tag
code to strip out the variation or configuration name from the scenario tags
(see listing 16.5)
|
Compare tagging strategies for resources needed by a few scenarios, most scenarios, or scenarios requiring different configurations. section 16.1
