7

I validating my components in Production it throws an Deploy Error:

Deployment Error:"Average test coverage across all Apex Classes and Triggers is 'X'%,at least 75% test coverage is required".The trigger intended to be deployed does not have any code coverage issue as its code coverage is more than 75% in the sandbox.

I Run All Apex Text Classes in Sandbox some classes are less then 75% code coverage then I modified the Test Classes then I try to deploy the Test Classes then also .But it throws same deploy error.

Best Regards, Ramesh


Thank you for responding.First two points are fine,But 3. My folks are Deployed some Triggers with out test Classes also. 4. Yes,One of apex test Class using hoard coded some UserId, How to resolve this issue?

Best Regards, Ramesh

2
  • 1
    you have less code coverage .Make sure overall code coverage is 75% and above and also all triggers have atleast 1% of coverage to deploy Commented Oct 19, 2013 at 11:14
  • Are you deploying the Test code for the trigger along with the trigger? Commented Oct 19, 2013 at 13:22

2 Answers 2

9

This is showing because the average code coverage is < 75% in the production org, and you need to work out why. Things to check are:

  1. Is code coverage in production over 75% before deploying? If not something is broken there that will need to be fixed first.

  2. Does production have any workflows or field validation rules that could be breaking your tests

  3. Are you definitely deploying your tests along with the trigger

  4. Does your trigger (or its tests) use any hard coded IDs, or rely on any data that's in the org? The test method should generate it's own data to work with, and IDs for record types etc. will be different between the orgs.

1
  • #1 above is typically the one that will haunt you during deployments. All are very valid tests for you... Commented Oct 19, 2013 at 23:23
0

I always put @isTest(SeeAllData=false) for all test methods. To test code which retrieves data I insert that data. For creating needed objects I create a TestHelper class which has a lot of methods like composeUser(...) or insertUser(...). This help me to reduce duplicates in test classes among all orgs where I'm coding. I'm using the same class in all orgs.

To test code with callout and SOQL you should perform all inserts before Test.startTest() call.

You must log in to answer this question.

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