Salesforce Q&A Part 7:
Apex Test Q)Why use test class in salesforce? Ans. Test class is important to check the sanity and sole purpose of custom apex code written for organization. Apex code having minimum 75% of test class coverage is considered healthy apex code. Q)How will the salesforce compiler knows you are writing a test class? Ans. Using @isTest annotation and static testmethod() are two things. Q)How to make the private variable and methods visible? Ans. Using @testVisible annotation. Q)What are the lines present in main code that are ignored in test class. Ans. System.debug statements. Q)How can we run the test class for particular user? Ans. using system.runAs(userProfile/username) Q) How to test asynchronous apex? Ans. Using Test.start?() and Test.stop(). Q) How do you write test class for web-service class? Ans. Define a mock test class implementing WebserviceMock interface for SOAP. and StaticResourceCalloutM...