function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priyanka DumkaPriyanka Dumka 

A user has all the access given using the sharing setting and he is able to login and access in org .. but we are getting errors in test class even after running it as system.runas or even after moving it to another env .What could be the possible reason?

A user has all the access given using the sharing setting and all other required access and he is able to login and access records in org .. but we are getting errors in test class even after running it as system.runas or even after moving it to another env .What could be the possible reason?
VinayVinay (Salesforce Developers) 
Hi Priyanka,

What is the error that you see?

Thanks,
Priyanka DumkaPriyanka Dumka
Hi Vinay ,

Getting permission related error while testing .But able to access the record in org .
Arun Kumar 1141Arun Kumar 1141
Hello Priyanka,

There could be several possible reasons why you're encountering errors in your test class, even though the user has all the required access and permissions. Here are a few reasons:
  1.  Check if the test class relies on specific data records that might not exist in the test environment or have different field values. Make sure that the necessary data is properly set up in the test environment or create the required test data within the test class itself.
  2. Verify the sharing settings in the test environment. Even though the user has all the required access, the test class may need additional sharing settings to be configured correctly for the records it is trying to access.
  3. Check if the test class has dependencies on external systems or APIs that might not be accessible in the test environment. Ensure that all required dependencies are available and properly configured.
This might help!
Thanks.