Showing posts from December, 2017

Apex Test Classes Interview Questions and Answers

Salesforce Interview Question on Apex Unit testing 
1. What is an apex Unit Testing? Why we need to write Test classes?

2. What is @isTest annotation? When you will use it?
When you define method or class using @isTest annotation then it only contains code used for testing your application. Test classes should be public or private only. Test class doesn't count against your organization limit of 3 MB for all Apex code.
private class MyTestClass {
   // Methods for testing
   @isTest static void test1() {
      // Implement test code
3. What is Test.startTest() and Test.stopTest()? When you will use it?
Test.startTest() and Test.stopTest() allow you to reset the governor limits within the context of your test execution and testing asynchronous classes. When Test.startTest() begins all the governor limits will be reset. and Test.stopTest() to end the execution of asynchronous process and switch back to the main context.

Points to remember when you use Test.startTest() an…