I noticed that when you create a user in a test class that the username must be unique in the real production environment. Most of my test classes are creating a user to then run the test method as.
The problem arises from the fact that you can create a test class, deploy it to production, and then have it break by someone else, coincidentally using that same username. Is there a best practice to avoid this besides trying to create long random usernames? Should we query for a random user in the org of that profile?
[email protected]