+ Start a Discussion
Chad MoutesChad Moutes 

Deleting Apex Class Issue

Hello All,

I am trying to delete an Apex Class, and its associated Test Class from my production instance. I am changing the status to Deleted and then doing the deploy to server from Force.com IDE. But it is failing due to code coverage issues, but the only class/trigger that is less than 75% CC is the class that I am trying to delete. Am I missing something?

Any and all help would be greatly appreciated.
Hi Chad,

In this case it would not allow you to delete the class which is having less code coverage.Either you have to move this class to Sandbox and then increase the code coverage and then push it to Sandbox and then perform Delete.

Another way of deleting the Classes is by making use of Workbench:

1)Go to Migration - retrieve - Click on Unpackaged Manifest(Choose File Button) - (Below XML file should be Prepared and should be selected in this case)

Create a sample Xml file of the below format :
<?xml version="1.0" encoding="UTF-8"?>
-<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<members>(It should consists of your class name you wanted to delete)</members>

2)It downloads an unpackaged Zip file.
3)Unzip the file and there would be a xml file named Your Classname.cls-meta.xml
4)Open the XML file.Change the Status to deleted.Save it
5)Zip the same file with the changed status
6)Go to Workbench - Migration - Deploy - Select the created Zipped Package

Do let me know, if it worked for you.


Chad MoutesChad Moutes

Thank you for your response. I definitely think that would work for me. But I actually decided to just comment out the classes instead of deleitng them for now. Thanks again though.