Activity › Forums › Salesforce® Discussions › What is meant By @testVisible in test class in Salesforce?
-
What is meant By @testVisible in test class in Salesforce?
Posted by Anuj on April 23, 2020 at 2:34 PMWhat is meant By @testVisible in test class in Salesforce?
Pooja replied 6 years, 1 month ago 4 Members · 3 Replies -
3 Replies
-
Hey Anuj,
Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn’t change the visibility of members if accessed by non-test classes.
With this annotation, you don’t have to change the access modifiers of your methods and member variables to public if you want to access them in a test method. For example, if a private member variable isn’t supposed to be exposed to external classes but it should be accessible by a test method, you can add the TestVisible annotation to the variable definition. - [adinserter block='9']
-
TestVisible Annotation. Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only.
-
This reply was modified 6 years, 1 month ago by
Manish.
-
This reply was modified 6 years, 1 month ago by
-
These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only. This annotation doesn’t change the visibility of members if accessed by non-test classes.
Log In to reply.