Activity Forums Salesforce® Discussions What is meant By @testVisible in test class in Salesforce?

  • Udit

    Member
    April 23, 2020 at 3:21 pm

    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.

  • Manish

    Member
    April 23, 2020 at 4:32 pm

    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 4 years, 8 months ago by  Manish.
  • Pooja

    Member
    April 23, 2020 at 4:35 pm

    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.

Popular Salesforce Blogs

Popular Salesforce Videos