Extracting Concepts
In Twist extracting a concept essentially means achieving a higher level abstraction of a business intent by combining two or more related business workflow steps. This higher level abstraction is referred to as Concept, and can be reused anywhere else in your test suite.
Extracting into Concepts is key to evolving your test suite, especially when your application is changing. Typically you start off expressing test intent in an imperative style and as the business intent becomes clearer you can abstract these steps and use language that expresses business intents at the correct level. This leads to two major advantages:
- More readable tests
- Better re-usability of tests
Consider the following example, a test which is trying to verify the inventory updating workflow. You may start off (not recommended) writing out a business operation as follows:
Example Scenario
- Start at the Maintain product catalog page.
- The page title should be “Joe’s musical —Maintain Product Catalog.”
- Click the Add New Instrument button.
- The page title should be “Joe’s musical—Add New Musical Instrument.”
- Enter text “Guitar” into the Instrument field.
- Select “Slide” from the Type selection list.
- Select “Dobro” from the Brand selection list.
- Click the Save button.
- The page title should be “Joe’s musical—Maintain Product Catalog.”
- The message should be “New instrument successfully added.”
- Instruments should be listed as follows:
- Click the Add New Instrument button.
- The page title should be “Joe’s musical—Add New Musical Instrument.”
- Enter text “Guitar” into the Instrument field.
- Select “Slide” from the Type selection list.
- Select “Dobro” from the Brand selection list.
- Click the Save button.
- The page title should be “Joe’s musical—Maintain Product Catalog.”
- The message should be “Error: The Instrument Guitar of type Slide and Brand Dobro already exists.”
| Instrument | Type | Brand | In Store | Number in inventory | Number sold so far |
|---|---|---|---|---|---|
| Guitar | Slide | Dobro | Yes | 20 | 5 |
| Drumkit | Standard | Yamaha | Yes | 10 | 3 |
You may then abstract this business operation to read
Example Scenarios after extracting concepts
- Add a New Musical Instrument “Guitar” of type “Slide” and brand “Dobro” (Extract a concept out of steps 1 to 8)
- Verify the Product Inventory
- Add a New Musical Instrument “Guitar” of type “Slide” and brand “Dobro” (Note you can reuse this step)
- Verify the message “Error: The Instrument Guitar of type Slide and Brand Dobro already exists”.
| Instrument | Type | Brand | In Store | Number in inventory | Number sold so far |
|---|---|---|---|---|---|
| Guitar | Slide | Dobro | Yes | 20 | 5 |
| Drumkit | Standard | Yamaha | Yes | 10 | 3 |
An additional benefit of writing such declarative tests is that your entire team can now more easily see the broader picture and can critically assess the test content. Acceptance tests must be correct and complete because they are a representation of the application requirements specification and also part of the automated regression safety net that the test suite provides