Activity Forums Salesforce® Discussions How do you perform unit test on a Salesforce trigger?

  • Avnish Yadav

    Member
    July 20, 2018 at 1:12 pm

    Hi Prachi,

    By using the description methods in salesforce you should be able to determine what the required fields are dynamically. But in my suggestion, you must check the required field before implementing the unit test on a particular Object.

    Thanks.

  • Parul

    Member
    September 11, 2018 at 6:25 pm

    Hi,

    Unit tests are class methods that verify whether a particular piece of code is working properly. Unit test methods take no arguments, commit no data to the database, send no emails, and are flagged with the testMethod keyword or the @isTest annotation in the method definition. Also, test methods must be defined in test classes, that is, classes annotated with @isTest.

    For example:

    @isTest
    private class myClass {
    static testMethod void myTest() {
    // code_block
    }
    }

     

    Thanks

  • shariq

    Member
    September 15, 2018 at 11:07 am

    Hi,

    I think you need to use schema class to get all fields and fill those values and then insert in your test class.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos