1

I am deploying some classes to UAT which have a code coverage over 80 % but deployment fails with the message "Your code coverage is 50%. You need at least 75% coverage to complete this deployment. DeactivateUsers" I cannot understand why it happening as I checked it a dozen of times that code coverage is well above required limit. What should be my next step to counter this problem

Note I am deploying only 3 classes not all the classes via Change Set and with test class in it and running only that test class during deployment.

marked as duplicate by battery.cord, Raul, Santanu Boral, Mr.Frodo, Ratan Paul May 29 '17 at 5:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You need to maintain your Org Codecoverage More than 75% then only you can deploy your coed via Change set. – user44771 May 26 '17 at 7:09
  • It is giving me name of a class which I was trying to deploy – Ishan May 26 '17 at 7:13
  • @Reshma I am only deploying 3 classes not all classes. – Ishan May 26 '17 at 7:14
  • First Run all Classes and check the overall org code coverage and then try to deploy once again. – user44771 May 26 '17 at 7:16
1

There could be multiple reasons for the same:

  1. Please cross check if you have used @Test(Seealldata = true) in your test classes (some/all of them), because then it's possible that your test data is not present in UAT, and that's why coverage is not getting up to expected. In that case, please avoid seealldata = true, and create your own test data in test classes. Please see link. http://www.sfdcpoint.com/salesforce/testsetup-method-in-apex-test-classes/
  2. Salesforce says overall coverage to be 75%, and it's possible that you might have some classes already in UAT, which are not covered at all. So, after deploying your classes with 80%, overall coverage is getting around 50%.

What you need to do is to analyze your UAT currently, and check what is the current code coverage. If it is zero or less than 75%, then you may need to write the test class for existing code first.

Hope this helps :)

  • 1 I am creating my own test data and not using @Test(Seealldata = true) 2 I think this could be the problem I think I should try other methods for deployment – Ishan May 26 '17 at 7:18
  • Then please check for the second possible reason, check your current code coverage of UAT, and then see. It must be less than 75% as of now, that is why after deploying 3 classes with 80%, it is getting to 50% overall. – Nitish Singhal May 26 '17 at 7:20
  • I checked on UAT code coverage is 76% over there – Ishan May 26 '17 at 7:29
  • Did you run all test in UAT recently? At the time of deployment which option did you choose? Run All tests OR Run specific tests. I would suggest, while deploying you choose Run specific tests option, and mention the name of test classes specifically created for your new 3 classes to deploy. Each class name should be in next line. Please try. – Nitish Singhal May 26 '17 at 7:33
  • I ran specific test and all 3 classes are interlinked so I think only one test class is needed – Ishan May 26 '17 at 7:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.