I think this script can be written as follows:
Given first name is John And last name is Smith
And the steps:
@Given("first name is $firstName") @And("last name is $lastName")
You can create a person object first to specify the first and last name in the "@Given" steps.
If you need to add another property, such as email, you just need to create one more step:
@And("the email is $email") public addEmail(String email) { person.setEmail(email); }
So this problem will not happen, and the code will be more reusable.
source share