Writing Apex unit tests
A test class is the only class in Apex that can have a private access modifier. It always runs when you want to deploy any Apex code to a production environment using the default tests, or when you create a managed package. Due to the fact that unit tests, in principle, are not called from outside the class, you can define your test class with the private access modifier.
A test class is always written with the @IsTest annotation. In this type of class, you are able to define regular methods and test methods. For instance, if you want to create your test data in one method and run this method in each unit test, you are able to create a regular method in your test class where you create your data. The unit tests (methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access