You need to sign in to do that
Don't have an account?

Test class coverage for list index
Hi, This following code is in my apex class.
In my test clas i can cover up List and followed by if condition, the bold part is not covering up. Please share me if any one have idea.
List < Forecast_Revenue_Report__c > getFlagVal = [SELECT Flag__c FROM Forecast_Revenue_Report__c WHERE Forecast_Month__c = : this.month1];
if(!getFlagVal.isEmpty()){
this.flag = getFlagVal[0].Flag__c;
Thanks.
In my test clas i can cover up List and followed by if condition, the bold part is not covering up. Please share me if any one have idea.
List < Forecast_Revenue_Report__c > getFlagVal = [SELECT Flag__c FROM Forecast_Revenue_Report__c WHERE Forecast_Month__c = : this.month1];
if(!getFlagVal.isEmpty()){
this.flag = getFlagVal[0].Flag__c;
Thanks.
All Answers
Forecast_Revenue_Report__c f = new Forecast_Revenue_Report__c(opp_id__c = '007Z000000YhjjjA', Forecast_Month__c = 'Jan_2014', Forecast_Amount__c = 500, Flag__c = 36);
insert f;
I think it is not matchong with 'Jan_2014'... can you check please???
Can you please tell what is the value of this.month1? is it the current month ? if so, then your record should be inserted with the value of Forecast_Month__c as Oct_2014 .. then your query will return values
other vice error will have no coverage...