You need to sign in to do that
Don't have an account?
Julie 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!
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!
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.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_controller_shell.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
http://eltoro.force.com/VisualForceExtensionTestMethods
https://webkul.com/blog/test-classes-in-apex-salesforce/
https://www.salesforcetutorial.com/what-is-unit-test-class-in-apex/
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:
https://salesforce.stackexchange.com/questions/82437/creating-test-class-for-vf-page-controller
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