Exercise 003: Remove Data Collector
Related Smell: 003 - The Data Collector
Purpose
- Learn to identify the
The Data Collector
smell. - Recognize how multiple
Given
steps
Your Task
Within the Customer.feature
file there is a scenario with multiple Given
steps, each collecting a part of the data needed in the following When
step. Identify the data collector and replace it with a consistent implementation.
Solution
Hint A
- You are looking for multiple
Given
step with only one parameter. - There are two
Given
steps which need to be called in sequence.
Hint B
- The relevant step are
Given the customer first name is "Max"
andAnd the customer last name is "Mustermann"
. - Look at the implementation in the step definition, how it clutters the scenario and the initialized fields.
- What happens if you only call one step?
- Identify an existing consistent expression instead.
Step by Step Walkthrough
- The relevant step are
Given the customer first name is "Max"
andAnd the customer last name is "Mustermann"
. - The consistent way to initialize
firstName
andlastName
is the stepGiven the customer name is Rose Smith
- Replace the original steps with
Given the customer name is Max Mustermann
- Delete the dead step implementations
Given the customer first name is "Max"
andAnd the customer last name is "Mustermann"
.