Q: 5
Universal Containers (UC) has a team that analyzes customer orders looking for fraud. This team needs access to Invoice records (custom object, Private organization-wide default). UC has complex rules to control users’ access. The architect recommended using Apex managed sharing to meet these requirements. Which recommendation should a developer consider when implementing the changes?
Options
Discussion
Makes sense to go with C here.
Option C A tries to trip you up but runAs is what really tests sharing from a real user perspective.
Option C that's the way to validate custom sharing logic with real user context in test methods. It's basically a best practice when you're dealing with Apex managed sharing and Private OWDs. I think that's what Salesforce recommends too, but open if someone has a different take.
C , runAs is what you need in Apex tests to mimic how different users would access these shared records. It helps check if your custom sharing rules work in all scenarios. Not 100% but can't see A or B fitting better.
C tbh. A is a classic trap since "Without Sharing" isn’t about user-level testing. runAs is pretty much the only way to simulate that in tests for Apex managed sharing.
Nice straightforward scenario. C makes sense because runAs lets you test sharing and permissions as specific users, which is essential for checking Apex managed sharing. Great way to validate the complex access logic UC needs.
A is wrong, C. Saw a similar question in a practice exam, and using runAs for testing custom sharing was the expected answer.
Its C. Had something like this in a mock and runAs was the right approach to test different user access with Apex managed sharing.
I think it's C for this case, since runAs is what you use in test classes to verify sharing works the way you want it for different users. Private OWD plus Apex managed sharing needs to be tested that way. Not totally confident, but can't see why A or B would fit better.
C You need runAs for testing Apex sharing scenarios, since profile-based permissions alone can't show every user's access. Anyone pick differently?
Be respectful. No spam.