Executing Apex tests in a deployment using Jenkins
In Salesforce code, coverage of Apex components should be more than 75% to deploy changes to production. If any test case fails during deployment, then deployment to production will also fail. To avoid this, it is recommended that you test your deployment in sandbox first before deploying it to production. Sometimes, individual code coverage of Apex components may be less than 75%, but overall code coverage for your organization should be 75% or more. To ensure test cases don't fail in production, you can execute a subset of test cases in sandbox after it's deployed. We have already seen deploying changes from one sandbox to another in the previous chapter. We just need to make small changes in build.xml
to specify the subset of tests to execute while deploying.
Here is a sample build.xml
with test cases to execute:
<target name="deployCode"> <sf:deploy username="${sf.username}" password="${sf.password}" sessionId...