function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ngabraningabrani 

Problems in uploading triggers to production using changeset

Hello,

I have three triggers and 1 test case that I am trying to upload from staging to production. In Staging I get a test coveragae of 85% when I run this one test case. However when I try to upload this changeset to production, I get an error that the test coverage is just 72% and the required test coverage is 75%.

 

Can I get more details on this 72%, when the test cases are being run during deployment. What is the breakup of test coverage  at class level. Also how do I view the debug log, when a change set is being deployed, on production, and test cases are being run at that time. All I am getting is a message like -

 

Deploy Error


Average test coverage across all Apex Classes and Triggers is 72%, at least 75% test coverage is required

 

Appreciate your help.

EnthEnth

When you run your unit test all you get is a % coverage that the test case is exercising in that class, not the total test coverage for the change set. If you Run Tests in Eclipse IDE, or via the Admin Setup, Apex Classes it should give you a more comprehensive report of the coverage of all classes. You can ignore warnings about classes not in your changeset.

 

Without a view of the classes in your changeset or your unit test it's harder to help any further - there are some very dirty tricks to get over the 75% if you're desperate but my experience is it's always worth the effort of getting your tests right.

hisrinuhisrinu

When you write your test classes you have to follow the best practices as shown in below link.

 

http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods

 

 

I think in your case you might have hard coded the record ids or your class is querying some records from staging in order to cover the triggers. If you do this way, obviously your code will fail in production as there are no records.

 

Follow the attached best practices and write your tests in an efficient way and good luck.