Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified Platform Developer II (Plat-Dev-301) Exam - Topic 7 Question 96 Discussion

A company notices that their unit tests in a test class with many methods to create many records for prerequisite reference data are slow.What can a developer to do address the issue?
B) Move the prerequisite reference data setup to a TestDataFactory and call that from each test method, and C) Move the prerequisite reference data setup to a @testSetup method in the test class.
A) Turn off triggers, flows, and validations when running tests.
D) Move the prerequisite reference data setup to the constructor for the test class.

Salesforce Certified Platform Developer II (Plat-Dev-301) Exam - Topic 7 Question 96 Discussion

Actual exam question for Salesforce's Salesforce Certified Platform Developer II (Plat-Dev-301) exam
Question #: 96
Topic #: 7
[All Salesforce Certified Platform Developer II (Plat-Dev-301) Questions]

A company notices that their unit tests in a test class with many methods to create many records for prerequisite reference data are slow.

What can a developer to do address the issue?

Show Suggested Answer Hide Answer
Suggested Answer: B, C

Contribute your Thoughts:

0/2000 characters
Ryan
6 months ago
@testSetup is faster for sure, saves a lot of time!
upvoted 0 times
...
Alex
6 months ago
Turning off triggers can help, but it's not a long-term fix.
upvoted 0 times
...
Kaitlyn
7 months ago
Surprised that people still use constructors for setup!
upvoted 0 times
...
Sarina
7 months ago
I disagree, using a TestDataFactory is more flexible.
upvoted 0 times
...
Rima
7 months ago
@testSetup method is definitely the way to go!
upvoted 0 times
...
Frank
7 months ago
I feel like using the constructor for setup could be risky; it might lead to issues if the tests depend on specific data states.
upvoted 0 times
...
Elden
8 months ago
I practiced a similar question where moving setup to a TestDataFactory helped with performance, but I wonder if @testSetup is better.
upvoted 0 times
...
Annett
8 months ago
I'm not entirely sure, but I think turning off triggers and validations might not be the best practice for tests.
upvoted 0 times
...
Malcom
8 months ago
I remember discussing the use of @testSetup methods in class; it seems like a good way to reduce redundancy.
upvoted 0 times
...
Deonna
8 months ago
I'm leaning towards option D. Putting the setup in the constructor seems like it could be a good way to ensure the data is available for all the tests in the class.
upvoted 0 times
...
Donette
8 months ago
Option C looks promising to me. Moving the setup to a @testSetup method could help keep the individual test methods clean and focused.
upvoted 0 times
...
Bette
8 months ago
Hmm, I'm a bit confused. I'm not sure if turning off triggers, flows, and validations is the best idea, as that could impact the accuracy of the tests. Maybe I should re-read the question and options more carefully.
upvoted 0 times
...
Kattie
8 months ago
This seems like a straightforward question. I think option B is the best approach - using a TestDataFactory to set up the prerequisite reference data.
upvoted 0 times
...
Edison
8 months ago
Okay, I've got this. Pods can run one or more containers, so option B is definitely true. And Pods are the smallest execution unit in Kubernetes, so option D is also true. I'll select those two.
upvoted 0 times
...
Kristel
8 months ago
Hmm, I'm a bit unsure about this one. I know configuration management is important for operations, but I'm not sure which of these options is the best explanation.
upvoted 0 times
...
Jess
8 months ago
This looks like a data modeling question. I think the key is to create a date table and establish relationships to the relevant date columns in the Orders table.
upvoted 0 times
...
Anastacia
1 year ago
Option D? Really? Move the data setup to the constructor? That's like putting the cart before the horse. What is this, amateur hour?
upvoted 0 times
Jacklyn
11 months ago
C) Move the prerequisite reference data setup to a @testSetup method in the test class.
upvoted 0 times
...
Malcolm
11 months ago
B) Move the prerequisite reference data setup to a TestDataFactory and call that from each test method.
upvoted 0 times
...
Mauricio
12 months ago
A) Turn off triggers, flows, and validations when running tests.
upvoted 0 times
...
...
Theresia
1 year ago
Hmm, I'm torn between B and C. Maybe I'll just flip a coin. Or better yet, I'll ask the developer sitting next to me. They'll definitely know the right answer.
upvoted 0 times
Emile
1 year ago
C) Move the prerequisite reference data setup to a @testSetup method in the test class.
upvoted 0 times
...
Mendy
1 year ago
B) Move the prerequisite reference data setup to a TestDataFactory and call that from each test method.
upvoted 0 times
...
Janae
1 year ago
A) Turn off triggers, flows, and validations when running tests.
upvoted 0 times
...
...
Julianna
1 year ago
I'm a big fan of Option A. Turning off all those triggers, flows, and validations will definitely speed things up. Who needs all that extra stuff anyway?
upvoted 0 times
William
1 year ago
I think using @testSetup method in the test class could also be a good option.
upvoted 0 times
...
Janey
1 year ago
But wouldn't it be better to have a separate TestDataFactory for the setup?
upvoted 0 times
...
Kimbery
1 year ago
I agree, turning off triggers, flows, and validations seems like the quickest solution.
upvoted 0 times
...
...
Teresita
1 year ago
I'm going to have to go with Option B. Creating a TestDataFactory and calling it from each test method seems more modular and reusable than the other options.
upvoted 0 times
Jenelle
1 year ago
And it would also make it easier to update the setup for the prerequisite reference data in the future.
upvoted 0 times
...
Ines
1 year ago
It would definitely help in keeping the test class clean and organized.
upvoted 0 times
...
Daron
1 year ago
I agree, having a TestDataFactory would make it easier to manage the setup for the test data.
upvoted 0 times
...
Renea
1 year ago
Option B sounds like a good idea. It would definitely make the tests more modular.
upvoted 0 times
...
...
Casandra
1 year ago
I personally prefer option A. Turning off triggers, flows, and validations can significantly speed up the tests.
upvoted 0 times
...
Chantay
1 year ago
Option C seems like the best solution. Setting up the prerequisite data in a @testSetup method will ensure it's only run once before the tests, rather than in each individual test method.
upvoted 0 times
Refugia
1 year ago
D: I think I'll try implementing @testSetup in my test class to see if it helps speed up the unit tests.
upvoted 0 times
...
Billi
1 year ago
C: I agree. It's important to optimize the test setup for better performance.
upvoted 0 times
...
Carlton
1 year ago
B: That's a good point. It can definitely help improve the speed of the unit tests.
upvoted 0 times
...
Tasia
1 year ago
A: Option C seems like the best solution. Setting up the prerequisite data in a @testSetup method will ensure it's only run once before the tests, rather than in each individual test method.
upvoted 0 times
...
...
Brandon
1 year ago
I disagree, I believe option C is the way to go. It will help keep the setup organized and separate from the test methods.
upvoted 0 times
...
Natalya
1 year ago
I think option B is the best choice. It will make the tests faster and more efficient.
upvoted 0 times
...

Save Cancel