function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Unit Test Mechanism

Hello All

I want to prepare a document on Unit Test mechanism of Apex classes and triggers. Can anybody suggest some links, where i can find good material for this topic.

Hi Manav,

Check below links

Check below link I have added one comment where you will find some use ful points .   

Below link wil help you how to cover catch block .

1.Tips for standardcontroller 
ApexPages.standradController con=ApexPages.StandradController(Needs to pass the instance of the standard/Custom Object);


ApexPages.standradSetController con=ApexPages.StandradSetController(Needs to pass the list of the standard/Custom Object);

Let me know if it helps !


Thanks Manoj :)

Let me study all material, if i have any further questions, will come back to you.
Check out this recent webinar, its really helpful and every minute is worth it.
You should subscribe to the Salesforce Developers YouTube channel. It has several webinars on Apex Testing from various events like DreamForce etc. which are far more useful and time saving than reading several PDFs and gaining a little.
Amit Chaudhary 8Amit Chaudhary 8
Single action
Test to verify that a single record produces the correct, expected result.

Bulk actions
Any Apex code, whether a trigger, a class or an extension, may be invoked for 1 to 200 records. You must test not only the single record case, but the bulk cases as well.

Restricted user
Test whether a user with restricted access to the sObjects used in your code sees the expected behavior. That is, whether they can run the code or receive error messages.

Positive behavior
Test to verify that the expected behavior occurs through every expected permutation, that is, that the user filled out everything correctly and did not go past the limits.

Negative behavior
There are likely limits to your applications, such as not being able to add a future date, not being able to specify a negative amount, and so on. You must test for the negative case and verify that the error messages are correctly produced as well as for the positive, within the limits cases.

Test Methods
Apply testMethod or @isTest to methods
      • Demarcates a single self-contained test
      • Signature characteristics:

Please let me know if this will help you.