Mapping impl code to modular steps
Suppose the activity in the previous scenario is created using the following code:
01 var testActivity = ActivityBuilder()
02 .withPriority(Priority.TC_URGENT)
03 .withDueInDaysFromNow(7)
04 .create(bundleObj)
The impl code appears as a single block. However, the impl code may need to spread across several methods. This is because scenario steps are designed to be usable in a variety of combinations. For example, some activity scenarios may specify the activity priority, but others may not. Therefore, each line of code must be assigned to a different method. The following table lists the scenario steps for the previous example and the impl methods that could be created to execute each step.
| Scenario step | Impl methods |
When I create an activity |
|
And the activity priority is "Urgent" |
|
And the activity is due in "7" days |
|
|
|
And I assign the activity using automated assignment |
|
Then the activity is assigned to my supervisor |
(not relevant to the creation of test data) |
The modularity of scenario steps can impose a requirement on impl methods. In some cases, multiple impl methods must share a common builder. Furthermore, the object must not be created from the builder until after all of the set-up values have been specified.
