Activity Forums Salesforce® Discussions Is it important to include @isTest on Testing Method in Salesforce? Explain? Reply To: Is it important to include @isTest on Testing Method in Salesforce? Explain?

  • Parul

    Member
    September 21, 2018 at 9:52 pm

    Adding some points:

    This class is defined using the @isTest annotation. Classes defined as such can only contain test methods. One advantage to creating a separate class for testing as opposed to adding test methods to an existing class is that classes defined with isTest don't count against your organization limit of 3 MB for all Apex code.
    The advantage to using separate test classes is that they do not count against the limit of the total amount of apex in your org (although this is a soft limit and thus not a overly compelling reason).

    @isTest
    public class TestUtil {

    public static void createTestAccounts() {
    // Create some test accounts
    }

    public static void createTestContacts() {
    // Create some test contacts
    }

    }

     

    Thanks