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
neeedhelpneeedhelp 

Where can I find a Test Class?

 Where can I find a test class written for a particular apex class.......I can only see the code covered for a particular class but unable to find the test class for it..... 

Best Answer chosen by Admin (Salesforce Developers) 
SabrentSabrent

Generally, based on naming convention the test class will have prefix or suffix - test and the name of the base class.

 

E.g if your base class is called SomeClass the test class must (if naming convention is adehered to) have names something like Test_SomeClass , SomeClass_Test, TestSomeClass, SomeClassTest  .

 

There may be better ways, but generally this is how i search - 

 

In the IDE do a search (Search > File) and type the name of the base class , this may bring up the test class.

 

 

OR

 

In your org, Develop > Apex Classes > View Test Classes (create a view if one doesn't already exist) and search the name of base class, you may find the test class

 

 

Hope this helps.

 

 

All Answers

snowMonkeysnowMonkey

Take a look at this section. This is where i got an idea of how this whole test thing works.

 

http://www.salesforce.com/us/developer/docs/workbook/forcecom_workbook.pdf

 

neeedhelpneeedhelp

 I yhink u didnt got my question.........In my dev org there is already a test class written for a particular class....I wanna see that test class....Hw can I view it

snowMonkeysnowMonkey

Logon and click on your name and then go setup.

 

on the left pane , go to App setup - Develop and if you are an admin, then you see apex classes and then click on the test class that you created.

 

hth!

SabrentSabrent

Generally, based on naming convention the test class will have prefix or suffix - test and the name of the base class.

 

E.g if your base class is called SomeClass the test class must (if naming convention is adehered to) have names something like Test_SomeClass , SomeClass_Test, TestSomeClass, SomeClassTest  .

 

There may be better ways, but generally this is how i search - 

 

In the IDE do a search (Search > File) and type the name of the base class , this may bring up the test class.

 

 

OR

 

In your org, Develop > Apex Classes > View Test Classes (create a view if one doesn't already exist) and search the name of base class, you may find the test class

 

 

Hope this helps.

 

 

This was selected as the best answer
SamuelDeRyckeSamuelDeRycke

Yes, to my knowledge there is no functionality to automatically find a related test class.   A best practise would be naming conventions, or having the test methods in your class itself (I prefer this). If neither is the case, and you have a lot of classes, you may need to browse through all of them (and go have a talk to whover coded it).