I know good test cases are isolated (that is, they don't depend on other tests or objects created by other tests). However, how should one proceed when a test becomes the precondition for another test?
As an example, let's say
test 1 validates a new user account can be created in the application under test (so test 1 will focus mainly on following the needed steps to create a user account). Then, another test, let's call it
test 2, verifies a user can log in with valid credentials. In order to do so, valid credentials should exist, i.e., the user account needs to be created. So
test 1 becomes a precondition for
test 2. If I want to run test 2 without having run test 1 first, it will fail. This doesn't sound like a desirable situation.
So how should I handle it? I have a suite written in Cucumber using Gherkin, where "Given" steps should be used to place test preconditions. So how can I use test 1 as a precondition for test 2? Is this even right?