Exercise 010: Replace Hardcoded Parameters
Related Smell: 010 - Hardcoded Parameters
Purpose
- Learn to identify the
Hardcoded Parameters
smell. - Understand how hardcoded parameters are introducing duplication and decreasing flexibility in your code.
Your Task
Within the Customer.feature
file there is a When
and Then
step witn a hardcoded parameter. Find at least
one such step definition and implement the correct assertion.
Solution
Hint A
- You are looking for steps with hardcoded paramters in the business calls.
- A hardcoded parameter is expressed in the Gherkin expression.
- Hardcoded paramters can be of any type. In our exercise you neeed to find two strings.
Hint B
- The relevant step is
When the customer Sabine Mustermann is searched
andThen the customer Sabine Mustermann can be found
. - Look in the
Customer.feature
file how it's used. - Are there any similar occurrances?
- What is you next step?
Step by Step Walkthrough
- The relevant step is
When the customer Sabine Mustermann is searched
andThen the customer Sabine Mustermann can be found
. - We introduce parameters for
firstName
andsecondName
. Implement it like inGiven the customer name is ...
. - The step with the expression
Then the customer can be found
is similar but uses fields instead orf paramters.