During our e2e testing, 100+ test users are created on our application. Workflow goes like this:

1. Generating a random password with faker library
2. Storing it in a variable
3. Using the variable to create the user 
4. Login as the created user and do some actions
5. Delete all the created users in the end(as part of teardown and via API)

These users will be deleted as part of cleaning up resources(teardown). From your point of view, is it better to generate passwords from faker or have a static password for all of these test users? Please share the pros and cons.

1 Answer 1


I would recommend taking a step back from the technical implementation of generating password values and consider what are the specific risks you're trying to mitigate with these end-to-end tests.

Is a randomly generated password actually important to the context of the test? If you are specifically testing password validation logic, then yes it might well be. If the test just needs a valid password value in order to create a user account then perhaps not.

By relying on random values generated by Faker (or any other random data generation tool), you would be introducing non-deterministic input data to your tests. Depending on the context of the tests this might be fine, or it might be problematic in ways you currently can't anticipate.

Some very limited pros/cons below.

Random Data Generation via Faker (or another lib/package)

Pros Cons
Integration with popular test frameworks e.g. Pytest Potential performance cost
Variation of data might expose unknown risks (e.g. validation logic) Changes to the Faker dependency could break your tests
Potential additional cognitive load (e.g. where does this password come from?)

The Ministry of Testing community has good content on managing test data.

For a wider discussion on guidelines and standards for test automation see here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.