You need to sign in to do that
Don't have an account?
SFDC@Chennai
How to cover the % level in Test class?
Hi I created test class and called save method through the reference(CustomObj__c co = new CustomObj__c(); co.save()), its covering only true part.
I need cover up the list creating/ inserting part, Please find the below image for your reference.
Thanks
I need cover up the list creating/ inserting part, Please find the below image for your reference.
Thanks
Can you Post your Controller and Test Class.
public MyClass (ApexPages.StandardController stdController) {}
public PageReference save() {
List < Report__c > foreRevRep = [SELECT Amount__c, Month__c, opp_id__c FROM Report__c WHERE opp_id__c = : this.oppId];
if (foreRevRep != null && foreRevRep.size() > 0) {
List < Report__c > frList = new List < Report__c > ();
if (opp.Select_Month_Division__c == '6' || opp.Select_Month_Division__c == '12' || opp.Select_Month_Division__c == '18' || opp.Select_Month_Division__c == '24' || opp.Select_Month_Division__c == '30' || opp.Select_Month_Division__c == '36') {
Report__c frr = new Report__c();
frr.opp_id__c = opp.Id;
if (this.amount1 != null) {
frr. Month__c = this.month1;
frr. Amount__c = this.amount1;
frr.Flag__c = 1;
frList.add(frr);
}
}
}
}}
@isTest
Public class MyTestClass{
Static testMethod void testMethod1(){
MyClass mc = new MyClass(new ApexPages.StandardController(o));
mc.save();
}
}
Note : Bold part is not covering
You have not written the Controller properly.
Check the below link for this.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm
And for test class try the below link.
https://developer.salesforce.com/forums?id=906F00000008y7QIAQ
If need more help, let me know.