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
Martin LöfflerMartin Löffler 

Code coverage issue for one time classes

Hello everybody, 

So I want to use a APEX Class for a one time correction of old data (process for updating contact addresses from accounts came to late). The (batch-)job is finished and works, but when trying to provide the class on my productive environment, I can´t because of missing code coverage.

But since the class won´t be triggered except by me and has no other influence on the system, I don´t understand why Unittests or such would be needed.

So, any idea how to circumvent the problem?

Greetings and thanks in advance

Martin

Best Answer chosen by Martin Löffler
Meghna Vijay 7Meghna Vijay 7
Hi Martin,
When deploying the class on production org there is a required thing to cover at least 75% coverage of that class. Are you sure about that you won't be needing it in future and once the job is finished you'd delete it ? If yes, then you can comment the method's code create a dummy test class calling it's method and then deploying it. Well this is not the best practice in my opinion.

Thanks 

All Answers

Meghna Vijay 7Meghna Vijay 7
Hi Martin,
When deploying the class on production org there is a required thing to cover at least 75% coverage of that class. Are you sure about that you won't be needing it in future and once the job is finished you'd delete it ? If yes, then you can comment the method's code create a dummy test class calling it's method and then deploying it. Well this is not the best practice in my opinion.

Thanks 
This was selected as the best answer
Martin LöfflerMartin Löffler

Hi Meghna,

Thanks already, it worked that far, that I got the class into my productive environment. But when I now want to uncomment the code of my class, it says (nearly as expected), that you "Can't alter metadata in an active org". Is there also a way to circumvent this?

Greetings Martin 

Martin LöfflerMartin Löffler

Hi Meghna,
I now wrote the testclass for a correct deployment, but thanks, I guess, you pushed me in the right direction ;)

Greetings Martin