When dealing with the highest level of the stack, functional end 2 end tests under no isolation, I am writing my selenium driven tests using the cucumber / BDD syntax and running each scenario in complete isolation on a forked JVM process.
Could I ask for some help on approaching the management of test data, currently I am using a randomisation technique, so for example lets say I have a user which has an expired attribute of true
and they cannot login, I may retrieve such user via the following:
@Given("^\"([^\"]*)\" is an expired \"([^\"]*)\"$")
public void is_an_expired_disabled(String userAlias, String userType) {
switch (userType.toLowerCase()) {
case "user":
cucumberWorld.addNewAccount(userAlias, XploreAccountProvider.expiredUser());
break;
case "manager":
cucumberWorld.addNewAccount(userAlias, XploreAccountProvider.expiredManager());
break;
}
addUserViaApi(cucumberWorld.getAccountByAlias(userAlias));
}
Now, this means I need to keep referencing such aliased user throughout the feature file, for example:
Given "Bob" is an expired "user"
When They try to login
Then They see the "expired.account" error message
What kind of approaches can we take so that we can run the same scenario over and over again, using the exact same data without the randomisation on each run, "Bob"'s information will vary on every execution right now because the User obj is populated with random data (that would meet the criteria for a valid test).
What approaches are viable here, do we create .json files of a user known as BoB and hardcode this scenario to go off and fetch such a user? concerns here is another layer of maintainance, if the user obj required changing in future, then all of these json blobs will require modifications.
What other approaches can we use? is the randomization a viable strategy?