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