We have a sample test class for covering the constructor in salesforce. Kindly see the below code. Controller:-
public class MyAccountClass { //Class Constructor public MyAccountClass(ApexPages.StandardController controller) { //Do Something } }
Test Class:- @isTest private class TestMyClass{ @isTest private static void testClass() { //Standard controller of Account is just an example //Create a new instance of Account Account acc = new Account(Name = 'TestAccountName'); //Insert the object virtually insert acc; //Create a new instance of standard controller ApexPages.StandardController sc = new ApexPages.standardController(acc); MyAccountClass controller = new MyAccountClass(sc); } }
We are the ISV Partners and Please reach us for custom development => www.merfantz.com
————————–Thank You!!!————————-