You need to sign in to do that
Don't have an account?
balraj singh 33
how reuse the data inserted in test class
how can we save the data inserted through query in test class and use it again for testing
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
There are two way to reuse the Test Function/Test Data
1) Create Test Factory (http://amitsalesforce.blogspot.com/2017/01/test-utility-classes-testdatafactory.html)
2) Use @testSetup (http://amitsalesforce.blogspot.com/2015/05/testsetup-set-up-test-data-for-entire.html)
Example 1) Test Factory
Test Class Should be like below
Example 2) @testSetup ( Set Up Test Data for an Entire Test Class )
Let us know if this will help you
You can create a method by using @testSetup annotation in this method you can insert the record that you want to use again and again.
So that you can use these records by using queries in other methods of the same test class.
Syntax:
@testSetup
static void setup()
{
//Records
}
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi