You need to sign in to do that
Don't have an account?
MnZ321
Help with Test class. Error: Compile Error: Constructor not defined: Beginner's attempt!
Following is my apex class. I keep getting 0 coverage and keep getting this error Error: Compile Error: Constructor not defined:
How can I remove the ERROR Compile Error: Constructor not defined. and also make data coverage
Thanks in advance
public class OrderTrackingList{ public OrderTrackingList(ApexPages.StandardController controller) {} public list<wrapgroupwise> singlegroup; public List<wrapgroupwise> getStartHere(){ singlegroup= new List<wrapgroupwise>(); List<orders__c> tempacc=[SELECT Id,Name FROM orders__c where id=:ApexPages.currentPage().getParameters().get('id')]; for(Integer i=0; i<tempacc.size() ; i++){ List <order_lines__c> tempOrderLines=[SELECT Id,name From order_lines__c Where order_number__c=:tempacc[i].id]; List <shipment_lines__c> tempShipmentLines=[SELECT Id,Name From shipment_lines__c Where Order_Number__c=:tempacc[i].id]; if(tempOrderLines.size()==0 && tempShipmentLines.size()==0){ singlegroup.add(new wrapgroupwise(tempacc[i],null,null)); } else{ if(tempShipmentLines.size()==0) { if(tempOrderLines[i].status__c=='Open') { tempOrderLines[i].calculated_estimated_delivery_date__c=tempOrderLines[i].planned_ship_date__c; } singlegroup.add(new wrapgroupwise(tempacc[i],tempOrderLines,null)); } else { if(tempOrderLines[i].status__c=='Open') { tempOrderLines[i].calculated_estimated_delivery_date__c=tempOrderLines[i].planned_ship_date__c; } if(tempOrderLines[i].status__c=='Invoiced') { tempOrderLines[i].calculated_estimated_delivery_date__c=tempShipmentLines[i].estimated_delivery_date__c; } if(tempOrderLines[i].status__c=='Shipped but not billed') { tempOrderLines[i].calculated_estimated_delivery_date__c=tempShipmentLines[i].estimated_delivery_date__c; } singlegroup.add( new wrapgroupwise(tempacc[i],tempOrderLines,tempShipmentLines)); } } } return singlegroup; } public class wrapgroupwise { public List<order_lines__c> con {get;set;} public orders__c acc {get;set;} public List<shipment_lines__c> opp {get;set;} public wrapgroupwise( orders__c a , list<order_lines__c> c,list<shipment_lines__c> o) { acc=a; con=c; opp=o; } } }And following is my Test Class:
@isTest public class OrderTrackingList_Test{ static testMethod void coverCode(){ OrderTrackingList ot = new OrderTrackingList(); ApexPages.StandardController sc = new ApexPages.standardController(ot); //GE_PW_OrderTrackingList.wrapgroupwise wgw = new GE_PW_OrderTrackingList.wrapgroupwise(); Profile pf= [SELECT Id FROM Profile WHERE name= 'System Administrator' LIMIT 1]; Account acc = new Account(Name='ABC Corp.'); insert acc; orders__c tempOrder = new orders__c(); tempOrder.name = '0001234567'; tempOrder.account__c = acc.id; insert tempOrder; List<orders__c> orderList = [SELECT Id, Name FROM orders__c limit 1]; ApexPages.StandardController sc = new ApexPages.standardController(orderList ); order_lines__c tempOL = new order_lines__c(); tempOL.Name = '10'; tempOL.number_of_order_lines__c = tempOrder.id; insert tempOL; shipment_lines__c tempSL = new shipment_lines__c(); tempSL.Name = '10'; tempSL.CurrencyIsoCode = 'USD'; insert tempSL; } }
How can I remove the ERROR Compile Error: Constructor not defined. and also make data coverage
Thanks in advance
Try the below code.
You should also set the current page to get the test coverage.
For more information check the below link.
https://developer.salesforce.com/forums?id=906F00000008y7QIAQ