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
kito kidkito kid 

test coverage

As I am new to Apex and salesforce, someone told me that I need to write test class for each class that I have written and test them.

 

If I don't have test class, I can't move to production.

 

Is that correct?

 

Why do I need to write test class for each class I have written? Actually, sometimes it is so troublesome as I need to write even a new class to call to external end point. Even though my actual method has been working and already tested to call to end point, when I wirte test calss, it won't allow me to call http method directly and need to even create new class as Mock.

 

As someone scaring me , if I don't finish test class, I can't move my code to production.

 

Any helpful link or useful explanation will be so much appreaciated.

Best Answer chosen by Admin (Salesforce Developers) 
RoyGiladRoyGilad
You must have at least 75% coverage of your code.
beside having something to validate your work it gives you a better understanding of what you have done and will be used as a backward compatibility tests for future development - a very good thing to have.


Also, please go through the links a bove posted by asish1989

All Answers

RoyGiladRoyGilad
You must have at least 75% coverage of your code.
beside having something to validate your work it gives you a better understanding of what you have done and will be used as a backward compatibility tests for future development - a very good thing to have.


Also, please go through the links a bove posted by asish1989
This was selected as the best answer