+ Start a Discussion
Julie CurryJulie Curry 

do I need to write a test class for my visualforce page?

I've created a visualforce page and a trigger in the past.  For the trigger I remember having to create a test class for it.  I had to ask Salesforce support to help me.  I'm not a developer.

Now I have another visualforce page I want to deploy and I'm wondering if I have to create a test class for this.  I don't recall having to create a test class for the first visualforce page.  How do I know when I need to create a test class?

Thanks in advance for your help!
Alain CabonAlain Cabon

You need to create test classes for the custom controllers and the controller extensions (apex code).

What is the first line (<apex:page>) of your visualforce page ?

<apex:page controller="MyController">

<apex:page standardController="Account" extensions="myControllerExtension">

The classes MyController and myControllerExtension need test classes.


Raj VakatiRaj Vakati
Refer this link 


Deepali KulshresthaDeepali Kulshrestha
Hi Julle,

You do not need to write Test Class for Visualforce Page Component.You have to write test Classes for Apex 
Controller only.
Please refer the below link:

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha