2

I am trying to instantiate a new controller. But every syntax I have tried shows an error.

Here is my code:

Class:

public  class MyNewCaseController {
    
    public string filterId {get; set;}
    
    public MyNewCaseController(ApexPages.StandardController  ctrl){
        string filter = ApexPages.currentPage().getParameters().get('filterId');
        if (filter != null)
            filterId = filter;
    }
}

Test:

@isTest
public without sharing class MyNewCaseListControllerTest {
    
    @isTest
    public static void testMyNewCaseController (){
        // Instantiate a new controller with all parameters in the page
        MyNewCaseListController controller = new MyNewCaseListController.MyNewCaseListController(ApexPages.StandardController ctrl);
 
    // Do something
    }
}

I get the error “Invalid type: CommunitiesCaseListController.CommunitiesCaseListController”.

If I try just

MyNewCaseListController controller = new MyNewCaseListController();

I get Constructor not defined: [MyNewCaseListController].()

If I try

MyNewCaseListController.MyNewCaseListController();

I get “Invalid type: MyNewCaseListController.MyNewCaseListController”

If I try

MyNewCaseListController controller = new MyNewCaseListController.MyNewCaseListController(ApexPages.ctrl);

I get “Invalid type: MyNewCaseListController.MyNewCaseListController”

What am I doing wrong?

0 Answers0