1

I want to deploy some of my classes (which are above 83% each) from sandbox to production. But it is showing code coverage error while deploying through change set.

There are other classes without test class in sandbox. By mistakenly I clicked run all tests in developer console. Is that the reason for showing code coverage error?

In my class, code coverage is showing like thisenter image description here

But it should should show like this..enter image description here

3
  • Where are you getting the code coverage error? while deploying in Prod?
    – Prady
    Sep 12, 2018 at 5:03
  • For all the negative markers, pls do explain as to why you are giving an negative vote as @salesforce 123 is a new contributor and some explanation could help him correct it in his next post
    – Prady
    Sep 12, 2018 at 5:16
  • 1
    Please take a moment to scroll through the tour and read How to Ask. As it stands, your question is quite vague. Please edit your question to be more specific about what you are deploying and what the results are. Screen shots may be used to good effect here.
    – Adrian Larson
    Sep 12, 2018 at 5:31

1 Answer 1

0

By running all tests in Sandbox is not going to affect anything while deploying in production env.

When you deploy a changeset it runs all tests in the prod env and its got nothing to do with classes in Sandbox without test class.

you can restrict the running of all test classes while deploying by also specifying only a single or multiple test classes by choosing the Run specified tests radio button and giving comma seperated names of the test classes to run.

Only the tests that you specify are run. Provide the names of test classes in a comma-separated list. Code coverage requirements differ from the default coverage requirements when using this level in production. The executed tests must cover the class or trigger in your change sets with a minimum of 75% code coverage. This coverage is computed for each class or trigger individually and is different from the overall coverage percentage.

enter image description here

Also take a look at the answers in the link below, there could be a pointer as to why your code is failing in prodn. Can't get code coverage over 75% when deploying to production

10
  • Yes, I selected run specified tests and gave 4 test class names. Again it is showing the same code coverage error ( but while testing those classes, it was showing 83, 86, 89, 90 respectively). Sep 12, 2018 at 5:30
  • Are you using seeAllData= true in your test classes? Read through @drakored answer in the link provided in the answer. It should cover most of the scenarios why you are getting code coverage error
    – Prady
    Sep 12, 2018 at 5:33
  • Also are you getting any other errors while deploying other than the code coverage errors? like a validation rule failing
    – Prady
    Sep 12, 2018 at 5:38
  • BTW.. what percentage cover are you getting while deploying ? did you add your test class in the changeset?
    – Prady
    Sep 12, 2018 at 5:45
  • How much % is getting covered? Are there any workflows or triggers running in prod and not running in SB or vice versa which could impact the data
    – Prady
    Sep 12, 2018 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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