Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Business Intelligence
  3. Question
Business Intelligence

Set OWD or Default Sharing Settings for Unit Testing session

Asked by Dipika Agarwal Jul 16, 2021 1.4K views 1 answer
Share

About this question

Is it possible to control the Organization Wide Defaults or Default Sharing Settings in effect when we run unit tests? Ideally we should be able to set different OWDs as a step in test setup so we can ensure the code will behave correctly under different OWDs that could be set in different organizations where the package/code is installed?

 How do I know what OWDs are set by default for a test run session? EDIT: I've noticed that if I set OWDs for my DEV org, then that's what applied for the unit-test session, which makes sense. But the issue is how do I change it as part of unit tests. My application behavior changes the OWD setting for Contact objects. If Contact OWD is 'Public Read/Write' it does one thing, and does another if it's 'Public Read Only' or less.

I'd like to test this change with a unit test, so that it behaves correctly under different configurations.

Does anyone know how to do either of following: Set the OWDs applicable for the unittest session using Apex in a test setup method? (Original Question) Run the same set of unit tests targeting different DEV organizations on which I set different OWD configurations manually? (Not the ideal, but something is better than nothing).


Your answer

1 Answer

More Business Intelligence discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Business Intelligence Blogs

Guides, tips and career advice on Business Intelligence from JanBask experts.