0

We have a Sandbox_1 where all unit tests are running properly, and we want to deploy our code to an entirely different organization via our repository

When running unit tests we have issues with sharing (users with custom profiles "hiringManager" see too many Job_Application__c records when unit tests are running with System.runAs(hiringManager)

What could be the reason of this?

OWD is the same for Job_Application__c, roles are also the same, profile "hiringManager" also have the same settings for Job_Application__c object.

What else should we check?

When doing deployment, this unit test fails, but when we deployed code to the Sandbox_0 (created from the Production that we want to deploy), the unit test is passing (but only when runned separately - not when all unit tests runs - because then it fails)

Are unit tests during the deployment via SFDX from repository is executed asynchronously? I think that during deployment, all unit tests run synchronously

I was using that command for deployment:

sfdx force:source:deploy -u user0@gmail.com -c -p force-app/main/default

3
  • What's your error message? How does it fail? Any additional details would be helpful. You can edit your post to include more information.
    – sfdcfox
    Oct 14, 2022 at 17:36
  • Do any of the failing tests use SeeAllData annotation?
    – Phil W
    Oct 14, 2022 at 18:31
  • 1
    1) There is a small number of settings which can't be retrieved (so can't be committed to source) and so I would analyse if there's any obvious settings which need to be manually enabled in the new sandbox. 2) Are you using the same user to run the tests manually and via sfdx? 3) The unit tests can be ran in parallel or sequentially depending on the settings in the Apex Test Execution 'options'. 4) What about criteria based/role based sharing rules? 5) You could retrieve the meta-data from both sandboxes and then use a compare tool like WinMerge to see if there's signficant delta. Oct 14, 2022 at 21:55

0

Your Answer

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