I have the following Gherkin:
Scenario: A user can register to the application
Given Carlos is not a registered user
When Carlos registers on to the application
Then he gets registered
My question has to do with the repetition of the test. What I mean is that I see this test failing if it runs for a second time. To make it more clear:
If we run the test the first time, Carlos is not registered in the app DB and as such he is registering and the outcome is that he gets registered in the app. The scenario for the first time will succeed.
The second time that we run the test, unfortunately, Carlos will be already registered on the app (DB) and as such the scenario will fail (as the given part will be invalid).
How do we solve such problems? Should we have some kind of a tear-up/tear-down DB or something?