8

I am having an issue, I have been with a company now and the person who came in before has deployed a bunch of stuff with no tests and shot the code coverage into the ground. I need to remove a bunch of his code but the production org keeps giving me an error from code coverage being bellow 75%. Also, I can't deploy my test classes I've recreated for the other apex classes that have little/no coverage. I am using Eclipse. Any suggestions would be great on either deleting the bad code or implementing my tests classes with out getting an error from salesforce.

Thanks.

  • Wait, your production org has <75% code coverage? That shouldn't be possible. Are some tests failing due to validation rules or other automation breaking them? – Mike Chale Sep 23 '13 at 15:08
  • They are failing due to a bunch of stuff and yes it is possible if you half-a** your unit tests. – AlphaBravo Sep 23 '13 at 15:12
  • 2
    You should be able to deploy the deletion of the old classes at the same time as you deploy your new test classes, and provided that the total coverage after is >75% you should be fine. If you're getting a coverage error still then that implies that even with those changes you aren't at 75%. You could do a bit of a shortterm hack and deploy a class with lots of lines doing nothing much but covered by a test as this will pull your coverage up. – Doug B Sep 23 '13 at 15:18
  • 2
    Fixed It. Turns out the code I was trying to delete was a REALLY old managed package. Got that uninstalled, and deployed ALL my updated unit tests at once. Went from ~50% to 89%. Thanks everyone for the suggestions. – AlphaBravo Sep 23 '13 at 16:54
8

You should be able to deploy the deletion of the old classes at the same time as you deploy your new test classes, and provided that the total coverage after is >75% you should be fine. If you're getting a coverage error still then that implies that even with those changes you aren't at 75%.

You could do a bit of a shortterm hack and deploy a class with lots of lines doing nothing much but covered by a test as this will pull your coverage up.

4

How far away from the magic 75% are you?

Can you fix the unit tests that are failing and bring the coverage up ? this seems like the best-case-scenario, however, I realize that the business sometimes wants you to deploy new code before fixing the technical debt of bad tests -- plus, who the hell honestly wants to fix broken, badly written tests from the last developer?

One thing you might be able to do -- aside from pulling the broken code/tests is to also deploy a well known, well tested, UNmanaged package. Some provide well in excess of the 75% needed coverage, and therefore contribute to net overall +75.

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.