Activity Forums Salesforce® Discussions What is the difference between Salesforce System.Assert and System.AssertEquals?

  • MOHIT

    Member
    January 27, 2020 at 3:02 PM

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

  • [adinserter block='9']
  • crazy

    Member
    May 17, 2024 at 3:53 PM

    wow, thanks for information

  • Clyde

    Member
    June 13, 2024 at 4:38 AM

    @tiny fishing while both methods are used for asserting expected outcomes in tests,
    `System.assert()` is used for general boolean conditions, and `System.assertEquals()` is specifically for comparing values for equality. Choosing the appropriate method depends on what exactly you are testing in your Apex unit tests.

Log In to reply.