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

Help with Coverage of Home Page Class
Hello and Hold on to your hats folks I got a doosie!
So the long and short is I am trying to implement a custom home page for my customer portal users. This has 2 buttons, submit a case to support and submitt a case to dev. I am using this class as a controller but I am not getting any coverage.
public class Home_Page_testsfdc {
public Home_Page_testsfdc() {
}
public Home_Page_testsfdc(ApexPages.StandardController controller)
{
}
public pagereference redirect1()
{
pagereference p=new pagereference('https://cs8.salesforce.com/500/e?retURL=%2Fhome%2Fhome.jsp%3Fsdtd%3D1&RecordType=012C0000000GGL3&ent=Case');
return p;
}
public pagereference redirect2()
{
pagereference p=new pagereference('https://cs8.salesforce.com/500/e?retURL=%2Fhome%2Fhome.jsp%3Fsdtd%3D1&RecordType=012C0000000GGL3&ent=Case');
return p;
}
}
The question then is, do I need to cover this code in the class itself or would I need to create a test class to cover this bad boy?
Kev
It's very similar to a regular apex class. The VF pages do not need to have code coverage, only the methods of the class, so you directly invoke as though it was a regular global class without any VF page.
Try something like this
All Answers
Apex controllers do need to have test coverage before they can be deployed, just like all other Apex classes in the Force.com API. You can create a separate test class, or if you roll back the API version on your class (v27.0 for example)you can create test method inside the controller class. You can get coverage either way, but if you use features that require v 28 or later, then just create a separate test class.
More on "Testing Custom Controllers and Controller Extensions"
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm
Thanks! I have been toying with this for a minute. How would I write a test class for this though? I ask because when writing a class for an object, I create records. But this is a class controlling a visualforce page that hosts the buttons. Not sure what to do here. Do you have an example that I could use?
It's very similar to a regular apex class. The VF pages do not need to have code coverage, only the methods of the class, so you directly invoke as though it was a regular global class without any VF page.
Try something like this
Thank you! Sir that works like a charm. You are a legend good sir!