Activity › Forums › Salesforce® Discussions › What is the difference between assert() and assertEquals() with example in Salesforce? › Reply To: What is the difference between assert() and assertEquals() with example in Salesforce?
MemberMarch 28, 2018 at 9:05 am
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.
System.assert(var1 == var2, "The value of var1 is: " +var1 + " and the value of... oh I mean it's just a variable");
If the second assertion fails the console will output the values of var1 and var2 with the labels “expected” and “actual”.
Hope this helps you more.