You need to sign in to do that
Don't have an account?
Kruz
Constructor not defined: [ApexPages.StandardController].<Constructor>()
Hello,
Please help me out to solve 'Constructor not defined: [ApexPages.StandardController].<Constructor>()' error while writing test class.
Original Apex Class:
Test Class:
Thanks,
Kruz Soni
Please help me out to solve 'Constructor not defined: [ApexPages.StandardController].<Constructor>()' error while writing test class.
Original Apex Class:
public class MassAcknowlgement { public List<CGR__RulesStudio__c> RuleList {get;set;} // private ApexPages.StandardSetController standardController; private Set<Id> accIds = new Set<Id>(); public MassAcknowlgement(ApexPages.StandardSetController standardController) { // this.standardController = standardController; RuleList = new List<CGR__RulesStudio__c>(); for(CGR__RulesStudio__c accs : (List<CGR__RulesStudio__c>)standardController.getSelected()){ accIds.add(accs.Id); } RuleList = [Select Id, Name,CGR__Rule_Description__c from CGR__RulesStudio__c WHERE ID IN :accIds]; } public void ListAck(){ List<CGR__Rule_Acknowledgement__c> ruleAck = new List<CGR__Rule_Acknowledgement__c>(); for(CGR__RulesStudio__c a : RuleList){ CGR__Rule_Acknowledgement__c ruleAc = new CGR__Rule_Acknowledgement__c(); // ruleAc.Name =a.Name; ruleAC.CGR__Rule_Description__c = a.CGR__Rule_Description__c; ruleAc.CGR__Rule_Name__c = a.Id; ruleAck.add(ruleAc); } insert ruleAck; } }
Test Class:
@isTest public class MassAcknowledgement_Test { static testMethod void MassAck(){ test.startTest(); RulesStudio__c rule = new RulesStudio__c (); ApexPages.StandardController sc = new ApexPages.StandardController (rule); MassAcknowlgement ma= new MassAcknowlgement(sc); ma.RuleList = new List<RulesStudio__c>(); ma.ListAck(); test.startTest(); } }
Thanks,
Kruz Soni
code
All Answers
Modify the StandardSetController from StandardController
Thanks for the reply but still I get the same error. please review the below test class and suggest me to how it will achieve 100% code coverage.
Thanks,
Apex Controller:
Visualforce Page:
Your code helps me to cover 68% code coverage
In test class, I have already used 'ext.ListAck();' with the help that method code coverage is gone upto 68% but 'FOR Loop' in controller is not coverd yet. do you have any idea about it. I tried to insert acknowledgement record but it not worked.
Thanks.
CGR__RulesStudio__c obj = new CGR__RulesStudio__c();
obj.name='test';
insert obj;
code
It will help me to cover 75%.