Introduction
Introduction, the usual song and dance! Why do we have to write test classes? What should be the thought process before you write the test classes? Why can we not see data in sandbox and production? Creating a basic Apex Test Class Test coverage for an Apex Method with params Writing the Test suite class for Triggers Testing the business logic using negation testing Doing the code coverage for an Apex Trigger How to do the code coverage for a private Apex method? @TestSetup in Test Classes How to create and work with Test Factory Design Pattern What is (SeeAllData = true) and when to use it? What is Test.isRunningTest() and how to use it for our advantage?
Doing the code coverage when we hit Exceptions
Code coverage for a method having Callout and DML in the same transaction Code coverage for a method throwing mixed DML exception 1/2 Code coverage for a method throwing mixed DML exception 2/2
Code Coverage for Asynchronous Apex
Doing the code coverage for Batch Apex Class Doing the code coverage for Schedule Apex Class Doing the code coverage for Queueable method Doing the code coverage for Future method Code coverage for chained Batch Apex Classes Another advantage of startTest() and stopTest()
Doing the code coverage by respecting the User context
System.runAs() in apex 1/2 System.runAs() in apex 2/2
Assert Class and Assert Statements
Getting your hands dirty with System.Assert statements How can we use isInsatnceOfType() in Assert class? A quick hack - How can Assert statements be helpful in debugging
Doing the code coverage for Apex Classes making REST API Callout
Test class coverage for callouts made in Apex
Doing the code coverage for REST API Apex Classes
Doing code coverage for custom REST API created using Apex 1/4 Doing code coverage for custom REST API created using Apex 2/4 Doing code coverage for custom REST API created using Apex 3/4 Doing the negation testing for the previous Alex Class 4/4 Why is RestResponse instantiated in test method?
Doing the code coverage for SOAP API Classes
Doing the code coverage for Apex Classes generated from WSDL 1/3 Doing the code coverage for Apex Classes generated from WSDL 2/3 Doing the code coverage for Apex Classes generated from WSDL 3/3
Others
Let’s have a look at all ways to mass run test classes