You need to sign in to do that
Don't have an account?
SFDC@Chennai
Test class coverage in apex
List < Report__c > frList = new List < Report__c > ();
How sholud i use the code for covering above line in apex test class? can any one have idea!!
How sholud i use the code for covering above line in apex test class? can any one have idea!!
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();
}
}
It is working fine with all the conditons and functionality, the only problem is test class wouldn't cover up those.
Both your controller and Test class seems to be incomplete.
1. I assume that this.oppId has valid not null value,
2. I assume that o has proper not null value in your test class,
Create some Report__c records in your test class with proper opp_id__c before calling mc.save().
In case this does not help you, please post your full code.
Regards
Akram
Your correct i removed if condition and checked the code coverage incresed ,but i have to use if condition can you please suggest some ideas .
Thanks in advance