function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Janis DavisJanis Davis 

Customer Portal Community & Chatter Answers Code coverage issues

I'm working with a customer that is unable to migrate config/code from their sandbox to production due to a 63% Apex Class code coverage. Their developer deterrmined that the code coverage issues are related to the Apex clases for their Customer Portal Community and Chatter Answers that is exposed in the CPC (see screen shot below). I logged a Case with SF Support, but was told that even thought the code issues are related to their product code, they do not provide Developer support to customers with basic support and referred me here to the developer boards for assistance. Also pasted below is more information on the coverage for these classes from their developer. Seems very odd to me that SF doesn't support their product code for all customers.

Any help or advice on  this will be most appreciated!

User-added image

More Information from their Developer
I was taking a look at the code and the tests that are there and I do not see any test cases that exercise the code in ChatterAnswersAuthProviderRegistration.
The naming on the classes and test cases are nicely consistent of the form '<class>' and '<class>Test’ for all except ChatterAnswersRegistration and ChatterAnswersCreateAccountTest .  But I can’t find any for the ChatterAnswersAuthProviderRegistration.

Also the other two that are low:

1. CommunitiesLandingController – forwardToStartPage() does not get exercised so that is probably why it is so low
2. chatter_answers_question_escalation_to_case_trigger – the exception code never gets executed and that is probably why it is so low.
Best Answer chosen by Janis Davis
NehalNehal (Salesforce Developers) 
Hi,

For ChatterAnswersAuthProviderRegistration class there is no test class being created by salesforce so you would have to create a test class for this class.
For CommunitiesLandingController and CommunitiesLoginController, below is the test class developed by salesforce. So you can modify the ""CommunitiesLoginControllerTest"" and ""CommunitiesLandingControllerTest"" as below which will increase the code coverage:

/**
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
*/
@IsTest public with sharing class CommunitiesLandingControllerTest {
    @IsTest(SeeAllData=true) public static void testCommunitiesLandingController() {
        // Instantiate a new controller with all parameters in the page
        CommunitiesLandingController controller = new CommunitiesLandingController();
        PageReference pageRef = controller.forwardToStartPage();
      }
}

/**
* An apex page controller that exposes the site login functionality
*/
@IsTest global with sharing class CommunitiesLoginControllerTest {
    @IsTest(SeeAllData=true)
    global static void testCommunitiesLoginController () {
        CommunitiesLoginController controller = new CommunitiesLoginController ();
        PageReference pageRef = controller.forwardToAuthPage();
    }   
}


For ""ChatterAnswersEscalationTriggerTest"", you would have to try to increase the code coverage. However, once you are able to increase the code coverage for other test classes of communities, then even if the code for ChatterAnswersEscalationTriggerTest"" remains 35%, you will be able to deploy your code.


"I hope this information has been helpful. If this has helped resolve your issue, please let us know by marking the post as ""Best Answer"" to help others in the community with similar questions."

All Answers

NehalNehal (Salesforce Developers) 
Hi,

For ChatterAnswersAuthProviderRegistration class there is no test class being created by salesforce so you would have to create a test class for this class.
For CommunitiesLandingController and CommunitiesLoginController, below is the test class developed by salesforce. So you can modify the ""CommunitiesLoginControllerTest"" and ""CommunitiesLandingControllerTest"" as below which will increase the code coverage:

/**
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
*/
@IsTest public with sharing class CommunitiesLandingControllerTest {
    @IsTest(SeeAllData=true) public static void testCommunitiesLandingController() {
        // Instantiate a new controller with all parameters in the page
        CommunitiesLandingController controller = new CommunitiesLandingController();
        PageReference pageRef = controller.forwardToStartPage();
      }
}

/**
* An apex page controller that exposes the site login functionality
*/
@IsTest global with sharing class CommunitiesLoginControllerTest {
    @IsTest(SeeAllData=true)
    global static void testCommunitiesLoginController () {
        CommunitiesLoginController controller = new CommunitiesLoginController ();
        PageReference pageRef = controller.forwardToAuthPage();
    }   
}


For ""ChatterAnswersEscalationTriggerTest"", you would have to try to increase the code coverage. However, once you are able to increase the code coverage for other test classes of communities, then even if the code for ChatterAnswersEscalationTriggerTest"" remains 35%, you will be able to deploy your code.


"I hope this information has been helpful. If this has helped resolve your issue, please let us know by marking the post as ""Best Answer"" to help others in the community with similar questions."

This was selected as the best answer
Janis DavisJanis Davis
Thanks Nehal! I appreciate your help on this. I noticed that you are from SF support and would like to understand why SF would release a product with code coverage issues and not support the code for customers with basic support. Is this something that will be fixed or will this continue to be an issue with CPC customers with basic support?

We are working on several other CPC projects, so any insight you can provide will be mmost appreciated.

Janis
NehalNehal (Salesforce Developers) 
Hi Janis,

This chatter answers is an app created by salesforce, however, any issues related to apex code even if that is related to salesforce app is something salesforce doesn't support. However, now we will be helping you with the issues for basic support on this community that is, if you need any help related to any issues you are facing, however, writing apex code is still beyond our supported boundaries in salesforce.

I hope this answers your question.