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

Apex Test class for a controller extension to a component in a Visualforce email



I've tested a number of controller extensions in Apex Test classes by calling the Visualforce page before, however I haven't had to test a controller extension for a Visualforce email page before and I'm a bit stumped.


Since there is no pagereference to call how do I test the Apex class (controller extension)??



Best Answer chosen by Admin (Salesforce Developers) 
As an update to this I have managed to test it by creating a dedicated Visualforce page. Seems a bit overkill to create a page just to test the code used in a Visualforce email but couldnt find any other way out there.


I also found that the component creates an empty method with the same name as the controller. Since the visualforce page didnt access this I had to call the empty method directly from within the test class to get 100% code coverage.