I have inherited an org with lots of outdated apex, and multiple changes to VRs, field requirements, field values, profile names, record type names etc. All of this was done without any insight into, or konwledge of, apex that had also been written many years ago.

Production code coverage is now hovering around 40%......

Most of the existing custom apex is now irrelevant (outdated processes that are no longer used) and I need to get coverage up so I can begin to push change sets and update the existing org.

Since my primary goal is to raise code coverage and then delete many of the existing classes, triggers, extensions, etc my question is: Can I simply replace existing class code with simpler classes and test classes rather than dig through and update the existing code and configuration?

Again, the goal is to get rid of a lot of this code anyway so this seems like a quick and dirty solution to an otherwise overwhelming problem.

Any thoughts?

1 Answer 1


In order to make any changes, you first have to get coverage up above 75%. Sorta of a circular problem.

  1. Identify any code that is no longer needed
  2. In sandbox, comment out all the code from step 1
  3. Update any test methods that are dependent on the commented code
  4. Update test coverage for remaining classes
  5. Deploy to production
  6. Delete the code in production that was commented out in step 1 and 2

This is a highly simplistic example though so you are going to have to think it through a bit

  • Thanks Eric. After a little more digging - can't I just flat out delete all of these 'old' classes through the IDE - and then not worry about updating anything. My goal is to get rid of a lot of this stuff anyway - so I'm wondering why bother with update classes and test classes if I don't have to.
    – jshea
    Commented Oct 8, 2015 at 13:26
  • IIRC, deleting requires a deployment (even when done from the IDE changing the status to deleted) so it must pass tests. Even so, you would have to delete the test class first then the class / trigger. IF you could do it with the existing poor code coverage, it would only work if the classes and test classes were completely isolated from other code. Give it a try if you are comfortable doing this sort of destruction in production but I would be cautious
    – Eric
    Commented Oct 8, 2015 at 13:29
  • Thanks Eric. Deletion from IDE didn't happen. So, going back to the original plan to update classes / test classes to get toward 75% coverage. Thanks for the insight!
    – jshea
    Commented Oct 9, 2015 at 0:02
  • @jshea - yea, its a tough road..if you get stuck maybe we can open up a chat windows and connect....
    – Eric
    Commented Oct 9, 2015 at 0:05

You must log in to answer this question.

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