You need to sign in to do that
Don't have an account?
SFDC@Chennai
Test Class for Negative part
HI
I wrote test class .
when i give the method name its covering only if part , else part is not covering
I need to cover the else part in test class
In test class I called the method as update();
My code is
public PageReference update() {
List < Forecast_Revenue_Report__c > getCheckEmpty = [SELECT Amount__c, Month__c, opp_id__c FROM Forecast_Revenue_Report__c WHERE opp_id__c = : this.oppId];
if (getCheckEmpty.size() == 0) {
return null;
} else {
List < Forecast_Revenue_Report__c > Output = [SELECT Amount__c, Month__c, opp_id__c FROM Forecast_Revenue_Report__c WHERE opp_id__c = : this.oppId];
if (Output.size() > 0) {
if (this.month1.contains(Output[0].Month__c)) {
if (Output.size() >= 1) {
this.amount1 = Output[0].Amount__c;
}}
Thanks in Advance
I wrote test class .
when i give the method name its covering only if part , else part is not covering
I need to cover the else part in test class
In test class I called the method as update();
My code is
public PageReference update() {
List < Forecast_Revenue_Report__c > getCheckEmpty = [SELECT Amount__c, Month__c, opp_id__c FROM Forecast_Revenue_Report__c WHERE opp_id__c = : this.oppId];
if (getCheckEmpty.size() == 0) {
return null;
} else {
List < Forecast_Revenue_Report__c > Output = [SELECT Amount__c, Month__c, opp_id__c FROM Forecast_Revenue_Report__c WHERE opp_id__c = : this.oppId];
if (Output.size() > 0) {
if (this.month1.contains(Output[0].Month__c)) {
if (Output.size() >= 1) {
this.amount1 = Output[0].Amount__c;
}}
Thanks in Advance
To get in the IF, you need to create data in your test method that match your conditions, so an Opportunity, Forecast_Revenue_Report__c, and to set this.oppId so that the query return lines.