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
Patrick Mayer 4Patrick Mayer 4 

Deploy Issues

User-added image

I have been trying to deploy an entirely unrelated class and keep running into this error. When I hit run test on Production these triggers get 90% and 100% respectively. I do not understand this error in this circumstance.
Best Answer chosen by Patrick Mayer 4
Caleb SidelCaleb Sidel
I don't know if I understand the issue entirely so I'll paraphrase:

You have code in production that right now, without deploying anything, if you click Run All Tests you get full coverage and the coverage of the triggers mentioned in the screenshot are 90% and 100%.
You also have new code in Sandbox that you'd like to deploy.
When you deploy the new code it fails.

So one thing to note: Anytime you deploy anything (chang set, via eclipse, via migration tool) all of the previous tests are run and they all have to pass and have coverage, actually it's a 75% average coverage across all code so in theory you could get away with a class haveing less than 75%. Note: triggers need at least 1% coverage.

So even though your new code is unreleated you still have to (ideally in Sandbox first) run all of the tests. And if you do this in Sandbox, hopefully you get some failures that might help you figure out the failures during deployment.

Things to look for: new validation rules you may be deploying that would crash existing tests, your existing code may not overlap persay but maybe your testmethods run the existing triggers when creating testdata and there is a conflict or vise versa?

I'm really just guessing, but my guess is that the tests that work now in Production are failing miserably because of something you're deploying (not the code mind you, the tests) and it's likely in the test data creation area. Valdiation rules typically the worst culprits of failed testMethods b/c the code was created before a field was required, etc.

Try deploying it via Eclipse and ChangeSet and post the debug logs in both cases, that might help us help you more! Good luck!

 

All Answers

Caleb SidelCaleb Sidel
I don't know if I understand the issue entirely so I'll paraphrase:

You have code in production that right now, without deploying anything, if you click Run All Tests you get full coverage and the coverage of the triggers mentioned in the screenshot are 90% and 100%.
You also have new code in Sandbox that you'd like to deploy.
When you deploy the new code it fails.

So one thing to note: Anytime you deploy anything (chang set, via eclipse, via migration tool) all of the previous tests are run and they all have to pass and have coverage, actually it's a 75% average coverage across all code so in theory you could get away with a class haveing less than 75%. Note: triggers need at least 1% coverage.

So even though your new code is unreleated you still have to (ideally in Sandbox first) run all of the tests. And if you do this in Sandbox, hopefully you get some failures that might help you figure out the failures during deployment.

Things to look for: new validation rules you may be deploying that would crash existing tests, your existing code may not overlap persay but maybe your testmethods run the existing triggers when creating testdata and there is a conflict or vise versa?

I'm really just guessing, but my guess is that the tests that work now in Production are failing miserably because of something you're deploying (not the code mind you, the tests) and it's likely in the test data creation area. Valdiation rules typically the worst culprits of failed testMethods b/c the code was created before a field was required, etc.

Try deploying it via Eclipse and ChangeSet and post the debug logs in both cases, that might help us help you more! Good luck!

 

This was selected as the best answer
Pramod_SFDCPramod_SFDC
Hi,

Please go through the link mentioned below. This might help you.

>> https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_best_practices.htm


Regards
Pramod