I'm trying to run two different test classes, but every time I do this, one of them shows error on the setup method, right in the line where I'm going to insert a new user. Is there a way to fix this? I've checked the depuration logs after executing the tesst, but they don't show anything that could tell where the problem is.
1 Answer
This error during unit tests generally means that a specific record was locked in one test while another tried to use it. Use @isTest(isParallel=false)
on each class to force them to run in serial, or use different users (e.g. create a new user) for each test class. Note that these errors won't stop your deployments, as deployments always run tests in serial mode, not parallel mode.
-
Hi @sfdcfox and thank you for taking your time answering my question. I've already tried adding the line you suggested, but the problem persists. I also tried running the tests in different order and the problem still appears. Edit: each test has a user named differently. Commented Aug 11, 2020 at 18:12