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
jjvdevjjvdev 

Testing loading a page

How does one test loading an opportunity record page?

There is an action that fires when the opportunity page is loaded (via a visualforce page).  I know the controller extension and action work because its been proven via the UI.  Just not sure to how properly write a unit test to load the page, and thus trigger the action to run.
Sujith NairSujith Nair
Take a look at the below documentation on how to test extensions/visualforce pages.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_error_handling.htm
jjvdevjjvdev
I don't see any documentation on how to invoke an action in a unit test.

Visualforce Page:
<apex:page standardController="Opportunity" extensions="numOpptyContactRoles" action="{!rollupOppContacts}" />

 
jjvdevjjvdev
Turns out it was as simple as invoking the method like normal.  For some reason I thought this was done differently.  But this worked fine.
numOpptyContactRoles.rollupOppContacts(opp.Id);

 
Jason Kuzmak 12Jason Kuzmak 12
@jjvdev

Glad you figured it out. Was just scratching my head over this myself.