Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What is the testsetup salesforce best practice?

Asked by Dipika Agarwal Apr 20, 2023 1.1K views 2 answers
Share

About this question

I'm trying to understand something so I can use @testSetup annotation wisely. As i read here:

By setting up records once for the class, you don’t need to re-create records for each test method. Also, because the rollback of records that are created during test setup happens at the end of the execution of the entire class, the number of records that are rolled back is reduced

But if you run a test class, you can see that all of the DMLs are recreated for each test method and not just once.

So what is the purpose of using it if I need to add an extra SOQL to retrieve the data I created in each test method? why not just use it in the test class itself and use it directly? just to reduce code duplication?

Your answer

2 Answers

Cleve Blick Latest answer

Answered on Feb 6, 2025

Enjoy the course on salesforce testsetup practices. Get access to great features with the help of the information source. Coreball has a simple design style, focusing on clarity and ease of follow, making the player experience smooth. The sound effects when shooting the ball and when completing the coreball level create a sense of excitement, helping the player immerse in each turn.

Was this helpful?

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.