You need to sign in to do that
Don't have an account?
Shawn Reichner 29
Test Class Error - Please help
I have created a VF Page to replicate a form that we use, with an extension to when the command button is pressed on the VF page will attach the form to the record the button to pull up the VF page was caled from.
I am now trying to test my test class and I am getting the following error message upon testing. "Methods defined as TestMethod do not support getContent call"
Can anyone help re-write or give suggestions on how to get this test class to test out the controller extension?
Appreciate any help!
Extension Code:
Test class Code:
I am now trying to test my test class and I am getting the following error message upon testing. "Methods defined as TestMethod do not support getContent call"
Can anyone help re-write or give suggestions on how to get this test class to test out the controller extension?
Appreciate any help!
Extension Code:
public class ArmorIncMDNAExtension { private final Contract__c contract; private ApexPages.StandardController standardController; public ArmorIncMDNAExtension(ApexPages.StandardController standardController) { this.Contract = (Contract__c)standardController.getRecord(); } public pagereference GeneratePDF(){ pagereference Pg = Page.ArmorIncMDNA; Blob pdf1 = pg.getcontentAsPdf(); Attachment d = new Attachment(); d.ParentId = contract.Id; d.Body = Pdf1; d.Name = contract.Account__r.Name + ' Armor Defense Inc. Mutual NDA.pdf'; d.ContentType = 'application/pdf'; insert d; return null; } }
Test class Code:
@isTest public class ArmorContractExtTest { static testMethod void tm1 () { Date myDate = Date.newInstance(2017, 8, 17); Contract__c c = new Contract__c(); c.Account__c = '001S000000rwY8H'; c.Auto_Renew__c = 'No'; c.Contract_Term_In_Months__c = 12; c.Effective_Date__c = myDate; c.Renewal_Period_Term_In_Months__c = 12; insert c; ArmorIncMDNAExtension ae = new ArmorIncMDNAExtension(new ApexPages.StandardController(c)); ae.GeneratePDF(); } }
Let us know if this will help you
All Answers
Try to create all test data in your test class like below
Let us know if this will help you
Thank you again for your attempt to assist I really appreciate it!
Shawn
Let us know if this will help you
Thank you sir! That did the trick and now I have 93 % code coverage. Thank you again for your awesome help!
Shawn