Test method to support getContent call

I have created getContent() method to send a pdf page in email using Visualforce page. But while running test method on the controller, I am getting following error message –
“Methods defined as TestMethod do not support getContent call, test skipped”
How to fix this problem.
Thank you in advance.


There’s a few ways to do this. My personal preference is to generate a different Blob for the body of the page depending on whether my code is running in the test context:

So if I have a reference to the page in variable pr:

   Blob content;
   if (Test.IsRunningTest())

and then do whatever I need to do with the body content.

Source : Link , Question Author : Rahul Nagardalekar , Answer Author : Bob Buzzard

Leave a Comment