You need to sign in to do that
Don't have an account?
SFDC Coder 8
Error in Test class Constructor not defined: [myClass].<Constructor>()
Hi All,
I am getting error in test class as constructor not defined.
Here is my code
Please help me in this error
What change I need to do
Thanks in Advance
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.StandardSetController control = new ApexPages.StandardSetcontroller(o); myClass pageControl = new myClass(control); pageControl.bumpCases(); pageControl.updateCases(); } }Controller Class
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
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Please update your test class like below Let us know if this will help you
All Answers
Thanks,
Dhruv
I tired that, same error I am getting
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Please update your test class like below Let us know if this will help you