You need to sign in to do that
Don't have an account?
Ola Bamidele
How to Cover "return detailPage;" Line In My Test Class
Hi Gurus,
I have finished writting my test class for my entension page and its curently on 92% coverage - as theres one line that is not covered. ( line 25 - return detailPage; )
This is my code extension apex class code:
public with sharing class extencntrl{
private ApexPages.StandardController sc;
public extencntrl(ApexPages.StandardController sc) {
this.sc = sc;
}
public boolean displayPopup {get; set;}
public void closePopup() {
displayPopup = false;
}
public void showPopup() {
displayPopup = true;
}
public PageReference Save() {
PageReference detailPage = sc.Save();
if (detailPage != null) {
PageReference editPage = new PageReference(Label.websiteurl);
return editPage ;
} else {
return detailPage;
}
}
}
This is my test class code:
@isTest
public class extencntrlTest{
static testmethod void validateStandardController()
{
Account acc = new Account();
acc.name ='Test';
insert acc;
ApexPages.StandardController sc = new ApexPages.StandardController(acc);
extencntrl ext = new extencntrl(sc);
ext.closePopup();
ext.showPopup();
ext.Save();
}
}
The only line that my test class does not cover is line 25 ( return detailPage;) on my extension.
Does anyone know what I can add to my code to cover the last line aswell? If so, please let me know!
Thanks very much!
I have finished writting my test class for my entension page and its curently on 92% coverage - as theres one line that is not covered. ( line 25 - return detailPage; )
This is my code extension apex class code:
public with sharing class extencntrl{
private ApexPages.StandardController sc;
public extencntrl(ApexPages.StandardController sc) {
this.sc = sc;
}
public boolean displayPopup {get; set;}
public void closePopup() {
displayPopup = false;
}
public void showPopup() {
displayPopup = true;
}
public PageReference Save() {
PageReference detailPage = sc.Save();
if (detailPage != null) {
PageReference editPage = new PageReference(Label.websiteurl);
return editPage ;
} else {
return detailPage;
}
}
}
This is my test class code:
@isTest
public class extencntrlTest{
static testmethod void validateStandardController()
{
Account acc = new Account();
acc.name ='Test';
insert acc;
ApexPages.StandardController sc = new ApexPages.StandardController(acc);
extencntrl ext = new extencntrl(sc);
ext.closePopup();
ext.showPopup();
ext.Save();
}
}
The only line that my test class does not cover is line 25 ( return detailPage;) on my extension.
Does anyone know what I can add to my code to cover the last line aswell? If so, please let me know!
Thanks very much!
Let us know if this will help you