Activity Forums Salesforce® Discussions What is utility class in Salesforce?

  • Manish

    Member
    April 13, 2020 at 12:30 pm

    Utility classes are helper classes that consisits of reusable methods. From triggers we can call methods in such public classes. This helps to reduce code with in trigger and make it more structured.

  • Marziya

    Member
    April 13, 2020 at 1:10 pm

    Hii Anjali,
    Public test utility classes are defined with the isTest annotation, and as such, are excluded from the organization code size limit and execute in test context. They can be called by test methods but not by non-test code.
    The methods in the public test utility class are defined the same way methods are in non-test classes. They can take parameters and can return a value. The methods should be declared as public or global to be visible to other test classes. These common methods can be called by any test method in your Apex classes to set up test data before running the test. While you can create public methods for test data creation in a regular Apex class, without the isTest annotation, you don’t get the benefit of excluding this code from the organization code size limit.

  • Sumit

    Member
    April 13, 2020 at 1:12 pm

    Utility classes are helper classes that consisits of reusable methods. From triggers we can call methods in such public classes. This helps to reduce code with in trigger and make it more structured

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos