Assert Class in Salesforce!

The Assert class in Salesforce contains a range of methods to help you validate your code and ensure its accuracy. 

Let's take a look at some key methods:

✅ areEqual(expected, actual, msg)
Verifies that the first two arguments are the same. This means their values, references, or states match.

✅ areNotEqual(notExpected, actual, msg)
Verifies that the first two arguments are different. This means their values, references, or states don't match.

✅ fail(msg)
Immediately stops code execution and returns a fatal error. Use this when you want to indicate a failure or halt test execution.

✅ isFalse(condition, msg)
Checks that the specified condition is false. Fails the assertion if the condition evaluates to true.

✅ isInstanceOfType(instance, expectedType, msg)
Validates that the instance is of the specified type. Fails the assertion if the instance is not of the expected type.

✅ isNotInstanceOfType(instance, notExpectedType, msg)
Validates that the instance is not of the specified type. Fails the assertion if the instance is of the unexpected type.

✅ isNotNull(value, msg)
Ensures that the value is not null. Fails the assertion if the value is null.

✅ isNull(value, msg)
Ensures that the value is null. Fails the assertion if the value is not null.

✅ isTrue(condition, msg)
Checks that the specified condition is true. Fails the assertion if the condition evaluates to false.

#Salesforce #Apex #Testing #SalesforceDeveloper #sfdcsaga

Follow Us

Posted By : Sudeer Kamat Date :

view_module Related

label Labels

Comments 0