SalesForce Deployment and Assertions

What is Salesforce Deployment? Deployment in Salesforce is the process of migrating metadata from one Org to another Organization. This Salesforce Deployment and assertion is used when promoting code from a sandbox or Developer Org into a production environment. The Metadata API facilitates deployment using either the IDE or the Migration tool. The IDE deployment process is the simpler of the two using a deployment wizard. The Migration Tool is a more advanced tool (at least for those without Apache Ant experience) but its own set of advantages.

Several mechanisms of Deployment are:

  • Changeset
  • eclipse.
  • ANT builder.

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, the PRD environment can be modified by the 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).

Returns recordsReturns fields
Records are stored in collectionsAll records are pertaining to different  S objects
All records are pertaining to single S ObjectSelecting fields in different tables from DB

Search in table single < S object > only returns records only

Search in entire Org (or) DB returns fields only
One dimensionalTwo dimensional 
Contains :






SOQL Syntax:-

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

SOSL Syntax:-

  • List < list > 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’) ;
 2 ways to Put Assertions

Second way

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 JavaScript 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

Eg: 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());

Eg: 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 Apps:
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.

Scroll to Top