How Does the Apex Code Coverage Work in User Stories?
The user story has a minimum apex code coverage which is coming from the Source Environment selected.
This is the minimum Apex test coverage that will be used in the Apex test results on the Org Credential detail page and when running tests in user stories.
In order to run a test in a user story, click on Manage Apex Tests to navigate to the Apex test page and then on Run Apex Tests.
This test will return the user story coverage in the source environment of the test classes included in the user story.
Please note that in order for the coverage of a test class to be calculated in a user story, both the class and the test class must be included in the user story.
Also, bear in mind that Copado is not the one running the test. Copado does a request to Salesforce, and it is Salesforce the one that executes the test. Copado will then display the results returned by Salesforce. Therefore, if there are any errors in the results, these 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 from being flagged 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 lower than the percentage set in the environment but higher than 75%, which is the minimum required by Salesforce.