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
Jose María Nicolás ArfelisJose María Nicolás Arfelis 

Which kind of codes need a "Test" part in Salesforce?

Hi all,

as I am a newbie in the programming world in Salesforce, I would like to know, which kind of codes in Salesforce need a "Test" part?.
Til now, I know Triggers need it, which other types of Codes need a "Test" part.

I would appreciate your answers.

Best regards.

 
UC InnovationUC Innovation
Hi Jose,

Basically ALL Apex code from Visualforce controllers to batch and schedule classes to triggers and simple apex classes. More information on this can be found here (https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods).

Hope this helps!

AM
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Triggers and Apex Classes(Batch Apex, Visualforce controllers, Email Services etc).
Jose María Nicolás ArfelisJose María Nicolás Arfelis
Thanks guys for your answers.
And what about this kind of simple lines?:

<apex:page action="{!URLFOR($Action.Account.List, $ObjectType.Account)}"/>

this apex code consists of only one line. Even this line needs a Test part?.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
This is a vf page, you don;t need to test the UI part in a test class. So, the answer is No
UC InnovationUC Innovation
Only Apex code requires code coverage. Visual force does not. In fact there is no way to using test classes.
UC InnovationUC Innovation
Please remember to select best answer if it helped resolve your issues so others can also benefit from this thread.