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

Calling getContent() in Test class

Hello ,

i want to add a method in test class,but since it contain getContent(), it is giving an error.Methods defined as TestMethod do not support getContent call.
Please suggest me if there any way to call this getContent() method.

This is my method - 

public PageReference attachPdf() {
        PageReference pdf;
        pdf= Page.Doc_TD;
        else if(Acc.Tier__c.equalsIgnoreCase('Wholesale')){  
        pdf= Page.Doc_WholeSale;
        else if(Acc.Tier__c.equalsIgnoreCase('SMD')){  
        pdf= Page.Doc_SMD;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.Error, 'Not supported now. Please select a tier.');
        return null;
        pdf.getParameters().put('id', documentId);
        Blob pdfBlob = pdf.getContent();
        Attachment a = new Attachment(parentId =, + '_'+ Acc.SMS_Date__c.year()+'_v'+(attachments.size()+1)+ '.pdf', body = pdfBlob, Description='Generate Version');
        PageReference finalPage=new PageReference('/'+documentId);
        insert a;
        return finalPage;
        ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.Error, 'Please Select Tier for Account ');
        return null;