2

I know that users are not considered as data in test classes. For example, I can still fetch a user from database, even if the test has SeeAllData=false annotation.

How about creating and inserting a user within a test method? Does it affect licensing? Can user inserts be freely used within tests or that's something that should be avoided?

3

It does not affect the licensing as any data created within a test is deleted after the test has finished running. See a great article here http://scox67.blogspot.co.uk/2013/09/unit-testing-tips-tricks-part-1.html?m=1 The part that will apply to you is Tip #4 on how to create users and use them using runAs() method.

If you need any help implementing let me know

| improve this answer | |
2

I have had test classes fail due to not having sufficient free licenses available whenSeeAllData=true while creating new users, but not when SeeAllData=false, both when needing to create a RunAs user and other users, such as Owners or community users.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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