You need to sign in to do that
Don't have an account?
Adarsh Bhat G
Criteria based sharing rule not applicable in Test Class
Hi,
I have an issue with test classes due the sharing rules. The account OWD setting is set to private. And there is criteria based sharing rule which shares account to all internal users.
In the test method, when we use System.runas(Internal User), the record is invisible even though the account should have been shared with all internal users by sharing rules.
There is an open idea for the similar issue :
https://trailblazer.salesforce.com/ideaView?id=0873A0000003eEWQAY
How can we make sure criteria based sharing rules is visible in Test classes?
Thanks,
Adarsh
I have an issue with test classes due the sharing rules. The account OWD setting is set to private. And there is criteria based sharing rule which shares account to all internal users.
In the test method, when we use System.runas(Internal User), the record is invisible even though the account should have been shared with all internal users by sharing rules.
There is an open idea for the similar issue :
https://trailblazer.salesforce.com/ideaView?id=0873A0000003eEWQAY
How can we make sure criteria based sharing rules is visible in Test classes?
Thanks,
Adarsh
Criteria Based Sharing rules aren't evaluated during Apex test classes
https://help.salesforce.com/HTViewHelpDoc?id=security_sharing_cbs_about.htm&language=en_US (https://help.salesforce.com/HTViewHelpDoc?id=security_sharing_cbs_about.htm&language=en_US)
The documentation states that "Criteria Based Sharing Rules cannot be tested" which I assume this refers to this.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Thanks,
Adarsh