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
Harshitha kaurHarshitha kaur 

When i tried to change access specifier from global to private in a test class its is showing this error - Enclosing type for global methods in apex classes must be declared as global ?? Is anyone there help me to solve this out?

Best Answer chosen by Harshitha kaur
Narender Singh(Nads)Narender Singh(Nads)
Hi,
I guess you are trying to change the access specifier of a class which contains a method declared as global. In order to resolve that, you must first declare that method as private. Only then you can set the access specifier of your class to private.

Let me know if it helps.
Thanks

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Can you please post your code. So that we can help you.

NOTE:- You can not access the Private method in Test Class. You need to use @TestVisible .
Narender Singh(Nads)Narender Singh(Nads)
Hi,
I guess you are trying to change the access specifier of a class which contains a method declared as global. In order to resolve that, you must first declare that method as private. Only then you can set the access specifier of your class to private.

Let me know if it helps.
Thanks
This was selected as the best answer
Harshitha kaurHarshitha kaur
I got it resolved , i removed global method in the class 
thanks Amit
Harshitha kaurHarshitha kaur
yes i did the same 
thanks nagendar