Author Archives: Biswajeet

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.

Synchronous and Asynchronous call in Salesforce

Synchronous:
In Synchronous process the thread waits for the task to be completed and then moves to the next task Sequentially. All the tasks are completed in a single thread.

Example:
Trigger
Controller Extension
Custom Controller

Asynchronous:
In Asynchronous call, the thread will not wait until it completes its tasks before proceeding to next. In a Asynchronous call, the tasks are run in different threads all together.

Example:
Batch
@future Annotation

Types of Sandboxes in Salesforce.com

Sandbox is a copy of the production organization. You can create multiple copies of your organization in separate environments for different purposes such as development, testing and training, without compromising the data and applications in your production organization.

Following are the different types of Sandboxes in Salesforce.com:
Developer Sandbox: A Developer sandbox is intended for development and testing in an isolated environment. A Developer Sandbox includes a copy of your production org’s configuration (metadata).

Developer Pro Sandbox: A Developer Pro sandbox is intended for development and testing in an isolated environment and can host larger data sets than a Developer sandbox. A Developer Pro sandbox includes a copy of your production org’s configuration (metadata). Use a Developer Pro sandbox to handle more development and quality assurance tasks and for integration testing or user training.

Partial Copy Sandbox: A Partial Copy sandbox is intended to be used as a testing environment. This environment includes a copy of your production org’s configuration (metadata) and a sample of your production org’s data as defined by a sandbox template. Use a Partial Copy sandbox for quality assurance tasks such as user acceptance testing, integration testing, and training.

Full Sandbox: A Full sandbox is intended to be used as a testing environment. Only Full sandboxes support performance testing, load testing, and staging. Full sandboxes are a replica of your production org, including all data, such as object records and attachments, and metadata. The length of the refresh interval makes it difficult to use Full sandboxes for development.

Sandboxes Available Per Edition:

Sandbox Type Professional Edition Performance Edition Unlimited Edition Enterprise Edition
Developer Sandbox 10 (change sets not available) 100 100 25
Developer Pro Sandbox 5 5
Partial Copy Sandbox 1 1 1
Full Sandbox 1 1

Note: You can buy more sandboxes for any edition except Developer Sandbox, which is bundled with add-on sandboxes of other types.

Sandbox Feature Quick Reference:

Sandbox Type Refresh Interval Storage Limit What’s Copied Sandbox Templates
Developer Sandbox 1 day Data storage: 200 MB File storage: 200 MB Metadata only Not available
Developer Pro Sandbox 1 day Data storage: 1 GBFile storage: 1 GB Metadata only Not available
Partial Copy Sandbox 5 days Data storage: 5 GBFile storage: 5 GB Metadata and sample data Required
Full Sandbox 29 days Same as your production org Metadata and all data Available

Test Setup Method in Salesforce Apex

In Spring ’15 release Salesforce has introduced new @testSetup annotation for Test class method. @testSetup annotation defined methods are used for creating common test records, and that records are available for all test methods in the class.

@testSetup methods create common test data easily and efficiently, and reduce test execution times especially when we are working with many records.

Example:

@iSTest
private class AccountControllerTest {
    
    //Test Setup Method
    @testsetup
    static void createAccount() {
        Account acc = new Account();
        acc.Name = 'Salesforce';
        insert acc;
    }
    
    //Test Method
    public static testMethod void test() {
        System.assertEquals(1, [SELECT COUNT() FROM Account Where Name = 'Salesforce']);
    }
}

Considerations:

  • Records created by @testSetup method are available to all test methods in the test class.
  • @testSetup methods are executed first in the test class before any test methods.
  • One Test class can have only one @testSetup method. If multiple @testSetup method is written in a Test class then sequence of execution of those methods are not guaranteed.
  • If the test class or a test method has access to organization data by using the @isTest(SeeAllData=true) annotation, test setup methods aren’t supported in this class.
  • If any error occurss during the execution in @testSetup method, then entire test class fails.
  • The data created by @testSetup methods will be rolled back after the completly execution of the test class.
  • If a test setup method calls a non-test method of another class, no code coverage is calculated for the non-test method.