简体   繁体   中英

Test users password- static or dynamic

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.

If you have good logging in the framework, using static or dynamic pass should make no difference in terms of analysis of test failures. Using dynamic password have the chance of discovering new bugs because you might hit on issues with the password constraints that were not expected and should not be there. My suggestion is to create passwordProvider method which accepts boolean flag isStatic so that you are able to change your mind on the fly.

Something like this:

public String generatePassword(boolean isStatic) {
if(isStatic) { return constant}
 else { password generation logic here}

}

I have used both approaches in different projects and cant say that one of them is superior in general.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM