+ Start a Discussion
ifthikar Ahmed 1ifthikar Ahmed 1 

why not @test setup

User-added image
Best Answer chosen by ifthikar Ahmed 1
Andrew GAndrew G
If we check the actual wording of the question:

"A developer wants multiple test classes to use the same set of test data."

Since we are saying classes , you would need the test utility.

If the question was
"A developer wants multiple test methods to use the same set of test data."

Then @testsetup would be the more likely answer. 

The key to remember is that the test data under the @TestSetup exists for the running of that Test class only.  It is available to all methods in that class, but not to other classes, or methods in other classes.

Regards
Andrew
 

All Answers

Team NubesEliteTeam NubesElite
Hi Ifthikar,
Normally, We use to follow this approach, creating Utility class for all records to be created and reused by various test classes.
And from individual testSetup, call those utility methods.
Since, the issue is @testsetup should be used in individual test classes and cannot be reused from other test classes that's why we have taken this approach.

Thank You
www.nubeselite.com

Developement | Training | Consulting

Please mark this as solution if your problem resolved.
ifthikar Ahmed 1ifthikar Ahmed 1
@Team NubesElite Thank you for the exlantion , so which one would be the right answer for this question 'C' or 'D'
Team NubesEliteTeam NubesElite
Hi Ifthikar,
I would say the answer is 'D'


Thank You
www.nubeselite.com
Developement | Training | Consulting


Please mark this as solution if your problem resolved.
Andrew GAndrew G
If we check the actual wording of the question:

"A developer wants multiple test classes to use the same set of test data."

Since we are saying classes , you would need the test utility.

If the question was
"A developer wants multiple test methods to use the same set of test data."

Then @testsetup would be the more likely answer. 

The key to remember is that the test data under the @TestSetup exists for the running of that Test class only.  It is available to all methods in that class, but not to other classes, or methods in other classes.

Regards
Andrew
 
This was selected as the best answer
ifthikar Ahmed 1ifthikar Ahmed 1
@ Andrew Great explanation thank you