You might face challenges while deploying a specific class to Production, Test class might show code coverage of about 75+% in Sandbox but the same test class while deploying to Production using "Run Specified Tests" might show code coverage less than 75%. As a result, Deployments will fail.
Let us begin the Troubleshooting using below Checklist.
Steps to Troubleshoot the issue :
~~~~~~~~~~~~~~~~~~~~~~~~~~
1. In Test class, we need to make sure that no real-time(DataBase) data is used and class level annotation should look something like below isTest(SeeAllData=false) or isTest()
More Information about seeAllData usage in Class/Method level: Using SeeAllData
2. In exceptional cases, we can use SeeAllData=true. Refer the below stack exchange link for few use-cases:
3. Follow the steps provided in the below article:
If the above steps did not resolve the issue, get ready to check the below checklist.
Advanced Troubleshooting:
~~~~~~~~~~~~~~~~~~~~~~~
1. Once done with the above steps, if you are still not able to figure out the root cause for the problem then add the Lazy plugin for chrome(assuming you are using chrome browser).
Click here: LazyLink
~~~~~~~~~~~~~~~~~~~~~~~
1. Once done with the above steps, if you are still not able to figure out the root cause for the problem then add the Lazy plugin for chrome(assuming you are using chrome browser).
Click here: LazyLink
2. Try Deploy/Validating the package in production [you can use ANT /Workbench / Changesets, any other deployment tool].
3. Navigate to the below path in Production :
Setup => In quick search type "Deployment Status". Copy the Id of recently validated/deployment results. This Id starts with the prefix "0Af".
4. Now, open the lazy window from your Production environment(click on the bookmark of the lazy plugin). In the Lazy tool search bar, paste the Deployment/Validation Id which is collected in the above step and click on the "Fetch Run Test Results" button.
5. Once we click on "Fetch Run Results" button, it will clearly show the lines of code which are not covered for a specific class during Validation/Deployment in Production.
6. Now, Login to Sandbox where the code coverage is greater than 75%. Only check the uncovered lines in Production and compare with sandbox if those lines are covered in the sandbox or not. If the same lines are covered in the sandbox then you can check the conditions which are stopping the deployment/validation in Production. This will help to FIX the issue.
Note :
You might be thinking why to additionally add a Lazy plugin? when the same information of uncovered lines are viewed using Workbench?
Answer: Suppose if your admin is doing deployment/ Validation through changeset then you will not get these (uncovered lines) details. So, instead of again re-validating the same package using the workbench, you can simply use the Lazy plugin.
I fixed 2 issues recently by following this approach.
tHiNk gooD and dO thE bEsT.........MANJU NATH 🌝
Comments
Post a Comment