Activity Forums Salesforce® Discussions What is the purpose or use of @TestVisible in salesforce?

  • Suraj

    Member
    April 28, 2017 at 1:29 pm

    Hi Saurabh,

    TestVisible annotation is used to allow test methods to access private or protected members of another class outside the test class.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

  • shariq

    Member
    August 8, 2017 at 1:57 pm

    Hi Saurabh,

    You can refer to this link.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos