0

I'm trying to deploy a change set to Prod but I get the following error: Average test coverage across all Apex Classes and Triggers is 67%, at least 75% test coverage is required. My change set only includes some custom fields, a page layout and a record type. I'm not sure why I'm getting this error or how to resolve it. Any assistance would be appreciated.

6
  • Have you tried running the tests in your sandbox? If you are deploying custom fields that are 'required' then this will break any tests that create the object you've added those fields if they've not been edited to populate your 'required' fields. Apr 15, 2014 at 18:35
  • At the risk of sounding dumb, what tests? None of the custom fields are required--they are all on the Product Object.
    – user7417
    Apr 15, 2014 at 18:43
  • Setup -> Develop -> Apex Classes -> Run All Tests, this will run all tests in your Org and let you know which ones are passing/failing. If none are failing then your issue is poor tests (i.e. ones that don't provide enough coverage). It's also possible that changes in your live environment may be causing tests to fail/low coverage there which won't be reflected in your sandbox. Apr 15, 2014 at 18:46
  • I went in there and ran all tests...looks like 4 are failing but they are all for Classes that are part of a managed package. I'm really not knowledgable with Apex code and test classes and I'm the only admin at a non-profit company. Is there any way to circumvent this error and get my declarative changes into Production without having to manually re-create them all?
    – user7417
    Apr 15, 2014 at 18:58
  • 1
    Managed package failures will not stop you deploying (thankfully), however it looks like you have an issue with your current test classes (i.e. they don't provide enough coverage). Without getting someone who knows Apex involved it's going to be very difficult for you to get around this as there is no way to circumvent the 75% coverage requirement for deploying changesets. Apr 15, 2014 at 19:02

2 Answers 2

1

This is documented. You will need to increase the code coverage by creating or improving your test classes.

If the deployment includes components for any of the following metadata types, all the tests are automatically run. ...

  • CustomField
  • CustomObject
  • ...

...

http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_deploy_running_tests.htm

1
  • Yes, I submitted a Case to SFDC and they told me which classes needed test classes created. Unfortunately I am not a developer and do not know how to create Test Classes and we do not have an SFDC developer on the team. I am the only admin. I had to replicate all changes manually and will have to continue to do so until I can learn how to write a test class. Thanks for everyone's input.
    – user7417
    Apr 23, 2014 at 18:32
1

Apex Tests get executed every time you perform a deployment. Therefore you will need to create the tests.

Using a tool like Copado Deployer instead of Change Sets can help you analyse such problems when performing deployments. The app available on the appExchange can be used for free (it's also much quicker than change sets). https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3dgGEAR

I had a friend email the developers at Copado who help with writing some apex tests, you can try to reach out to them (www.copa.do).

Otherwise check out the documentation here: https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .