If I am building a test class for a custom controller, I generally start like this and I dont have any issues:

CustomControllerExtensionNameccn = new CustomControllerExtensionName();

However, as this custom controller is not an extension of a stadard controller, so the VF page will look like this:

    apex:page controller="CustomControllerName" extensions="CustomControllerExtensionName"

I cant use this system. After many hours of google I only found examples to test for custom controllers that are extensions of an standard controller, but not for custom controller


instead of

CustomControllerExtensionNameccn = new CustomControllerExtensionName();

Replace for

    CustomControllerExtensionName ccen = new CustomControllerExtensionName(new CustomControllerName());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.