-3

> Here is the class where i need unit test

public class extCtrlEx 
{

private final account acc;
public extCtrlEx(ApexPages.StandardController controller) {
this.acc=(account)controller.getRecord();
}
public string getGreetings(){
return 'Hello '+acc.name ;
}
public void display(){}

}

I tried unit test it populates error like Compile Error: Constructor not defined: [extCtrlEx].() plz help to resolve the issue.

@isTest

public class extCtrlEx_TC

{

static testMethod void testMthd()
{
Account acc=new Account();
//  extCtrlEx ece=new extCtrlEx ();

//    ece.display();

//    ece.getGreetings();

}
}   

2 Answers 2

2

You need to construct a StandardController and pass that as a parameter to the constructor for your controller. StandardController needs one parameter: the account SObject you just created.

0
0
@isTest

public class extCtrlEx_TC

{

static testMethod void testMthd()
   {
      Account acc=new Account();
      ApexPages.StandardController ext =new ApexPages.StandardController(acc);
      extCtrlEx exc = new extCtrlEx(ext);

      System.assert('Add your assertion');
   }
}   
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .