+ Start a Discussion
SFDC Coder 8SFDC Coder 8 

Error in Test class (Constructor not defined: [myClass].<Constructor>(ApexPages.StandardController) )

Hi All,
I am getting error in test class as constructor not defined.
Here is my code
@isTest
public class myClass_Test
{
public static testMethod void testMethod() {
        account acc = new account();
        acc.Name = 'test account';
        acc.F1__c='test';
       
        insert acc ;
        contact con=new contact();
        con.LastName=acc.F1__c;
     
        Obj1__c o = new Obj1__c ();
        o.F1__c = acc.Id;
        o.F2__c= con.LastName;
        
        
        insert o;
        
        
    PageReference myPage = Page.myPage;
    myPage.getParameters().put('id', o.Id);  
    Test.setCurrentPage(myPage);    
    ApexPages.StandardController control = new ApexPages.Standardcontroller(o);
    myClass pageControl = new myClass(control); 
     pageControl.bumpCases();
     pageControl.updateCases();   
     
    }

}

Controller
public with sharing class myClass 
{
    private ApexPages.StandardSetController standardController;

    public myClass(ApexPages.StandardSetController standardController)
    {
        this.standardController = standardController;
    }

    public PageReference bumpCases()
    {       
        // Get the selected records (optional, you can use getSelected to obtain ID's and do your own SOQL)
        List<Obj1__c> selectedCases = (List<Obj1__c>) standardController.getSelected();

        // Update records       
        for(obj1__c selectedCase : selectedCases)
        {
            if(selectedCase.status__c == 'Saved') 
                selectedCase.status__c = 'Cancelled';
            
        }       

        return null;        
    }

    public PageReference updateCases()
    {       
        // Call StandardSetController 'save' method to update (optional, you can use your own DML)
        return standardController.save();   
    }
}

Visualforce Page
<apex:page standardController="obj1__c" extensions="myController" recordSetVar="Items" action="{!bumpCases}">
   <apex:form >
       <apex:pageBlock title="Bump Selected Items">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!updateCases}" value="Confirm"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!selected}" var="o">
                <apex:column value="{!o.status__c}"/>
               
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>   
</apex:page>

Please help me in this error
What change I need to do
Thanks in Advance
hammmhammm
Please change the order.
    ApexPages.StandardController control = new ApexPages.Standardcontroller(o);
    myClass pageControl = new myClass(control); 

    PageReference myPage = Page.myPage;
    myPage.getParameters().put('id', o.Id);  
    Test.setCurrentPage(myPage);
ApexPages.StandardController is called with Test.setCurrentPage and an error has occurred.
SFDC Coder 8SFDC Coder 8
Hi Hammm
Its not working