SalesForce Deployment and Assertions

SalesForce Deployment

In this particular section let us explore about various SalesForce Deployment and Assertions.

First , let us see “What is Deployment?” The answer is very simple, Deployment is nothing but connection between sandbox and PRD environment (production organization)

  • Several mechanisms of Deployment are:

                             |→    Change set

                             |→     Force.com eclipse

                             |→      ANT builder

                             |→      Web service

Hot Deployment:

During the Hot Deployment , if we exclude an object from the sandbox then it will be omitted from the PRD environment as well . However, PRD environment can be modified by Development environment without stopping the apps at prod area.

Differences Between The SOQL and SOSL :

Let us evaluate between SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language).


SOQL Syntax:-

  • Select fn1,fn2,fn3,- – –  – fnn from < S object >

SOSL Syntax:-

  • List < list <S object >> ss=Find ‘ pattern’ IN Fields

                             Returning field name1, field name2, – – – –  –


  • Assertions are used to terminate the execution of the program based upon a condition
  • If some condition matches, the program won’t execute
  • If the condition is true, execution stops at that point or else it will continue till the end .

How to Put Assertions into the Code:


There are generally two ways to Put Assertions into a Code:

  1. System.asserts equals ( val1, val2, ‘string’) ;
  2. System.asserts not equals ( var1, var2, ‘string’) ;



Winter ’12 for developers’

                                       →  App logic

1) Public Test Classes In Apex:

  • Classes annotated with @istest no longer have to be private. You can now create public test classes that expose common methods for test data creation . These public methods can be called by tests outside the test class for setting up data that the tests need to run against.
  • Let us look at an example of a public test class that contains utility methods for test data creation:

             @ Is Test

                 public class TestUtil {

                 public static void create TestAccounts () {

                  // create some test accounts


                 public static void create TestContacts () {

                   // create some test contacts



2) JSON Support In Apex:

Native classes for serializing and deserializing JSON

  • Native Java Script Objects Notation (JSON) has been added to Apex in Winter’12
  • Using JSON classes, you can now parse (resolve) JSON content and serialize Apex objects in the JSON format

The following classes have been added for JSON support:

  • System.JSON: It contains methods for serializing Apex objects into JSON format and deserializing JSON content that was already serialized using the serialize method in this class.
  • System.JSONGenerator:  Contains methods to serialize Apex objects into JSON content using the standard JSON encoding
  • System.JSONParser: Represents a parser for JSON– encoded content


       List invoices = new List ();

        invoices.add (inv1);

        invoices.add (inv2);

        //Serialize the list of Invoice Statement objects.

        String JSON String = JSON.serialize (invoices);

       System.debug (‘serialized list of invoices into JSON format:’+ JSON String);

         // Deserializing the list of invoices from the JSON string

       List deserialized Invoices = (list) JSON.deserialize(JSON String, List.class);

      System.assertEquals(invoices.size(), deserializedInvoices.size());


       Http httpProtocal = new Http();

       // create an HTTP request to send.

        Http Request request = new Http request();


        Http Response response = http protocol.send (request);

        // Create JSON parser with the http response body

       // as an input string.

      JSON Parser parser= JSON.create Parser (response.get Body());

3) Async Test API (Beta):

Integrate With Testing For Continuous Integration App’s:

  • Two API objects are now available to enable starting asynchronous test runs as well as for checking test results:

Apex test queue item: Represents a single Apex class in the Apex Job Queue

Apex test result:Represents the result of an Apex test method execution

You can use this functionality to better integrate with test execution in continuous integration applications.

4) New System Methods:

  • New methods are being used for determining the execution content in the system class:


Determines if the currently executing code is invoked by batch Apex Job


Determines if the currently executing code is invoked by code containing in a method annotated with @future


Determines if the currently executing code is invoked by a scheduled Apex job.

Enroll for Instructor Led Live SalesForce Training at Mindmajix

0 Responses on SalesForce Deployment and Assertions"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.