Skip to main content

How to write test class of the following apex class

public with sharing class DisplayAttachAccountController {

    

    private String parentId {
        set;
        get;
    }
    public List < Attachment > attList {
        get;
        set;
    }

    public DisplayAttachAccountController(ApexPages.StandardController stdController) {
        this.parentId = stdController.getId();
        System.debug('&&&&' + parentId);
        attList = [SELECT ParentId, Name, Id, ContentType, BodyLength FROM Attachment
            WHERE ParentId in (Select Id from opportunity where accountId =: this.ParentId)
        ];
    }

}

@isTest
public class AttachTesting {
    static testmethod void validateAttach(){
        Account obj = new Account(Name ='Test');
         insert obj;

        //apexpages.currentpage().getparameters().put('id' , yourID);

        ApexPages.StandardController stdController;
      DisplayProfilePictureController conAttach= new DisplayProfilePictureController(stdController);  

    }
}