function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rama krishna 181rama krishna 181 

6. difference b/w system.assert and system.assertEquals...?

6. difference b/w system.assert and system.assertEquals...?
Suraj TripathiSuraj Tripathi
Hi Rama,

System.Assert accepts two parameters, one (mandatory) which is the condition to test for and the other a message (optional) to display should that condition be false.

System.AssertEquals and System.AssertNotEquals both accepts three parameters; the first two (mandatory) are the variables that will be tested for in/equality and the third (optional) is the message to display if the assert results in false.

For more info, you can check out the below link :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_system.htm

Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Regards ,
Suraj
vijayabhaskarareddyvijayabhaskarareddy
System.assertEquals
System.assertEquals(arg1,arg2) asserts if arg1 and arg2 are same, else it throws an error. It is mainly used for tracking errors.
two inputs  are mandatory

Example1:

//Perfect System.assertEquals
try
{
    Integer i =90;
    System.assertEquals(i,90);
}
catch(Exception e)
{
}

Example2:

//Erroneous System.assertEquals
try
{
    Integer i =95;
    System.assertEquals(i,90);
}
catch(Exception e)
{
}

System.assert()
=================
System.Assert accepts two parameters, one (mandatory) which is the condition to test for and the other a message (optional) to display should that condition be false.

// System.assert(var1 == var2, "  Error Message ");

integer i= 10;
Integer j=11;
system.assert(i==j, 'i value  not equal to j ');

//Error Message: : 'i value  not equal to j