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
Ravi_SFDCRavi_SFDC 

How to find the exact test class for the APEX Trigger

Hi,

I do have a concern. How can we find the exact APEX Test Class for the respective APEX Ext Class and APEX Trigger.

Example: Someone in the org has written a APEX Trigger and now i need to change the code, i dodn't even know that whether that Trigger has a Test Class or not. How can i find the Test Class for the respective Trigger in the ORG. Your help would be really appreciated.

Thanks & Regards
Ravi.

srlawr uksrlawr uk
The trigger will have test coverage, because it's a requirement in Salesforce to do so in order to release them - the quality and coverage therein is entirely up to them though.

To find out what covers a class, the easiest way is to launch the developer console (Select "Developer Console" from the drop down menu under Your Name in the top right)

From there, open the Apex Trigger class and in the top left, there is a drop down that sayd "Code Coverage: xx%"

Click that, and it will give you a breakdown of each class, and indeed each method, that is contributing to the coverage of that trigger.

coverage

 
Ashish Borate 9Ashish Borate 9
This depends on previous test results stored in apex test history. If you are having brand new org / sandbox this becomes difficult to find code coverage contributor test classes.

To find test classes, go to developer console > ctrl+shift+o (open file) > enter *<objectname>*test.. if you are following best practices for class naming you shoul get the desired results.

e.g. for TaskTrigger try searching *task*test, you can run these test classes, after all test classes are run, go to tasktrigger and find code coverage contributors by clicking on 'code coverage: all tests' -- refer image above..