May 2019
Intermediate to advanced
546 pages
12h 41m
English
The @TestSetup annotation is a bit special. With this method, you are able to define your test data, which will be created for each of the test methods in the same class. Take a look at the following example:
@IsTestprivate with sharing class MyTestClass { @TestSetup private static void createMyTestData(){ } @IsTest private static void myTestMethod1(){ // test data defined in the method createMyTestData is created before the execution of this unit test } @IsTest private static void myTestMethod2(){ // test data defined in the method createMyTestData is created before the execution of this unit test }}
The first method in this class (which has the @TestSetup annotation inside of it) will contain the creation of the test data. This ...
Read now
Unlock full access