Skip to main content

Return to TX Community

Liaison

Resolving Code Coverage errors for Communities

Issue: Code Coverage Failure errors when Deploying or Validating the changeset for Communities upgrades for items NOT related to the items in your changeset. Such as: “The following triggers have 0% code coverage…”

code coverage errors

Resolution Option 1: Run single Test Class

When you validate the Changeset, run only the Communities Test Class (TX_TestCommunities); this is the Test Class for everything related to Communities:

  1. Navigate to Setup and search for Inbound Change Sets.
  2. Click the Validate link for the change set you previously created.
  3. Click the option to Run specified tests.
  4. Enter TX_TestCommunities.
  5. Click Validate. If you still receive errors, contact TargetX Support.

inbound Changeset

Note: While we still recommend to Run all Tests, the above option should be used if you get an error.

Resolution Option 2: Update TX_TestCommunities


The other option you have is to update the TX_TestCommunities Apex Class.

Step 1    Log into your Sandbox

Ensure that your Sandbox has been refreshed before continuing.

Step 2    Update TX_TestCommunities Apex Class

  1. Navigate to Setup and search for Apex Classes.
  2. Click the TX_TestCommunities apex class.
  3. Select Edit.
  4. Add the following code to the end of testSiteLoginController ():
PageReference pageRef = Page.TX_SiteLogin;
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('startURL','testurl');
System.PageReference selfRegURL = controller.getSelfRegURL();
System.assert(selfRegURL != null);

For example:

example apex class

  1. Save your changes.

Step 3    Test the changes in your Sandbox

  1. Login to your Community using an existing test user.
  2. Verify they can create an Application, submit payment, etc.
  3. Register a new test user.
  4. Verify they can create an Application, submit payment, etc.
  5. Test any additional processes that are important to your institution.

Step 4    Create an Outbound Change Set

  1. Navigate to Setup and search for Outbound Change Sets.
  2. Select New
  3. Name the Change Set, for example, Community Code Coverage.
  4. Add a Description and Save your changes.
  5. In the Change Set Components section, select Add.
  6. Select a Component Type of Apex Class.
  7. Click the checkboxes for the following Apex Class:
    • TX_TestCommunities

Step 5    Upload your Change Set

  1. From the Change Set you created above, select the Org you want to send the Change Set to.
  2. Click Upload.

Note: Uploading the Change Set will send it to the Target Org; it will NOT change your production Org until you Deploy the Change Set.

Step 6    Validate the Change Set in your production Org

  1. Login to your production Org.
  2. Navigate to Setup and search for Inbound Change Sets.
  3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
  4. Click the Change Set you want to deploy.
  5. Click Validate.

If you get Code Coverage errors, please see the article: How do I fix Code Coverage errors when validating an Inbound Change Set for Communities?

Step 7    Deploy the Change Set in your production Org

  1. Login to your production Org.
  2. Navigate to Setup and search for Inbound Change Sets.
  3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
  4. Click the Change Set you want to deploy.
  5. Click Deploy.

For additional information on deploying Change Sets, please see Salesforce Help & Training article Deploying a Change Set.

  • Was this article helpful?