Unable to Commit a Test Class in a User Story

You may have committed an Apex class in a user story and later you need to add the Apex test class to the same user story in order to calculate the test coverage.

If you commit the test class alone without making any changes, this will result in a commit with the status No changes and the test class won't be added to the user story. This is the expected behavior. Based on the architecture of Copado, committing the class alone will produce a commit with the status No changes.

If you run into a situation where a test class needs to be added to a user story, the class has already been added to the user story and you do not want to change anything in the test class, you have several options:

  1. Create a new user story and commit both the Apex class and the test class again.
  2. Use the Recommit Files Git operation with the Re-Create Feature Branch checkbox enabled.
  3. Delete the test class file in the feature branch and commit the test class again in the same user story. This will recreate the test class in the feature branch which is consider a change and the commit will be successful.

Any workaround where you manage to commit the class and test class making changes in the feature branch will work. If you make any changes in the test class, this will result in a successful commit even if the test class is committed alone.

Note: If you are using Copado v11 or over, you can use the Add Test Classes feature to add test classes to the user story even if the classes have not been modified. The classes added with this feature will not be committed or deployed.

How did we do?