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
RatherGeekyRatherGeeky 

How can I delete defunct classes when code coverage is below the threshold?

I have several legacy classes (around 20 of them) and triggers (about 5) that are no longer being used and I need to delete from our Salesforce org. However, our code coverage is currently 74% (needs to be at least 75%) because of issues with the code/test classes in those very same classes.

I've tried modifying the xml in Eclipse to set them to inactive/deleted but when I try to validate deploying those changes, I get errors on the test classes of the code that I am trying to remove. I've also attempted to follow these instructions to temporarily boost test class coverage just in order to remove those classes that are unnecessary. But again, the errors on the test classes won't allow me to continue deployment.

It seems that I have to first improve the test classes (note: I am not a programer and this code was written by someone no longer at my company) so that coverage improves in order to then delete them. 

I've tried combing through the errors... if I can make a change that will bump us up even by 1% that would resolve the issue I think... but I've got very minimal understanding of how the code functions and don't even know where to start.

Any suggestions?



 
RatherGeekyRatherGeeky
Okay, after a LOT of testing (and maybe a few tears), I finally figured out a solution that seems to be working. I'm still slogging through, but for posterity, in case anyone else runs into a similar problem,here's how I resolved this. 

I'm not sure which of the following steps were necessary, but I'll share them all just in case. 
  1. I recompiled all my classes. (Setup -> Apex Classes -> Compile all classes)
  2. I made sure I had a copy of all code in a secondary sandbox by creating a new project in Eclipse.
  3. In my primary sandbox, I updated one controller at a time to just remove all the code between { and }. 
  4. When I tried to validate the deployment, I received a variety of errors. But by doing these in small batches of 4 dependent classes at a time or so, I was able to gradually remove the code that was causing the problem and then deploy basically an empty class.
This was very labor intensive and took some trial and error, but I'm very pleased that eventually it seems to have worked out!