Activity Forums Salesforce® Discussions How can I cover exception part in a class using test class in Salesforce?

  • Prachi

    Member
    November 19, 2019 at 4:11 pm

    Hi,

    In your testmethod, insert records in such a way that it will cause the exception to occur. This will cover the exception lines as well.

    try this in your test class.

    try
    {
    //perform actions like insert,update,delete...etc that causes your exception to occur
    system.assert(false);
    }
    Catch(exception e)
    {

    }

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos