You need to sign in to do that
Don't have an account?

Apex & unit tests
Hi,
What is best way to write unit tests for an Apex class ? The known options are listed below.
1. Write the test in seperate Apex class.
2. Write test in an inner class in the same apex class.
3. Write test same apex class at the bottom.
I used option 1, but had a problem with writing tests for private methods. Finally I had to make all of them public, which I don't think as not good practise.
Can I use @IsTest annotation for inner class or test methods ?
Thanks
Viraj
What is best way to write unit tests for an Apex class ? The known options are listed below.
1. Write the test in seperate Apex class.
2. Write test in an inner class in the same apex class.
3. Write test same apex class at the bottom.
I used option 1, but had a problem with writing tests for private methods. Finally I had to make all of them public, which I don't think as not good practise.
Can I use @IsTest annotation for inner class or test methods ?
Thanks
Viraj
That's a great question you raise. We've just published an article on test methods:
An Introduction to Apex Code Test Methods
I've just asked the author if he can look at some of your questions as well. You make a good point about the testing of private methods....
Jon
Thank you very much for your feedback.
Viraj