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
apexuserapexuser 

profile issue while running the test case

Hi Folks,

                I have written a test case and its run well and code coverage is morthan 75%.My profile is Restricted System Administrator.

 

The same test class when ran by my friend it just throwing an error.His profile is Syatem Administarator.

 

How to resolve this issue, so he also should be able to run successfully.

 

Thanks,

Rajeshwar.

sebcossebcos

Hi,

you should use the runAs feature for Apex test methods to make sure that you run the tests in the context of a user who is supposed to use your application and not the context of the user who is running the tests.

This will avoid the issue you are having currently since the test will be user/profile specific.

Here is the documentation with an example:

http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_testing_tools_runas.htm?SearchType=Stem .