How does the Apex Code Coverage works in User Stories?

The user story has a minimum apex code coverage which is coming from the Source Environment selected.

That is the Minimum Apex Test Coverage which will be used for Apex Test Results on the Org Credential detail page and also the Minimum Apex Test Coverage when running the tests in the User Stories.

In order to run the test in the user story you need to click on the button “Run Apex Text” in the user story.

This will return the User Story Coverage in the source environment for the test classes included in your user story. Please note that in order for the coverage to be calculated for a test class in the user story, the class and the test class must be included in the user story. 

Bear in mind that Copado is not the one running the test. Copado does a request to Salesforce and it's Salesforce the one running the test. Copado will display the results returned by Salesforce therefore, any error displayed in the results will have to be fixed in the source environment of the user story where the tests were run.

There is a validation rule in the User Story object that will prevent the user story to be marked as “Promote Change” or “Promote and Deploy” if the “User Story Coverage” is lower than the “Minimum Apex Code Coverage”.

Copado will not stop the deployment if the coverage in the destination org (calculated during the deployment) is less than percentage set in the environment but higher than 75% which is the minimum required by Salesforce.

How did we do?