I have been using Force.com IDE to work on VisualForce pages and classes directly in a live development environment. I was unaware of the requirement that 75% of your code had to be covered by tests. Suddenly today, when I wanted to change one line of code in one of my classes, the file fails to save with this error message:
Average test coverage across all Apex Classes and Triggers is 15%, at least 75% test coverage is required.
So I wrote some test methods to get the coverage for the class I am working on to 78%, but it still won't save. Catch 22?
What shall I do?
Update:
I am trying to improve my code coverage by adding tests in my sandbox org and then deploying that to the development org via change sets. For example:
- I take a class that has no coverage
- write some test methods that covers the code more than 75%
- make a new change set and add the class
- upload the change set to my development org
- when I try to deploy the change set in my dev org, the deployment fails with
Deploy Error | Average test coverage across all Apex Classes and Triggers is 15%, at least 75% test coverage is required.
Also trying to deploy one class via Force.com IDE fails with the same method. Does this mean that I can't fix and deploy class by class?