I need to write a test coverage code for a getter, setter methods in a controller class
public Boolean showNtc {
get {
if (reg[0].Status__c == 'Review') {
return true;
} else {
return false;
}
}
private set;
}
in a VisualForce page code is like below
<apex:outputPanel id="step2" rendered="{!showNtc}"
Everything is working fine, expect i'm unable to execute above code by a test class. I tried several ways, but i failed.
In order to cover this code with test you have to emulate at least 2 states:
reg[0].Status__c == 'Revire'
reg[0].Status__c != 'Revire'
Also I recommend to consider the case when
reg
has no records because this might cause NPE.So in your tests you need something like that