exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 59 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 59
Topic #: 1
[All Certified Platform Developer II 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?

  • A. Move the prerequisite reference data setup to a TestDataFactory and call that from each test method.
  • B. Move the prerequisite reference data setup to a @testSetup method in the test class.
  • C. Move the prerequisite reference data setup to a static method in the test class and call that from each test method.
  • D. Move the prerequisite reference data setup to the constructor for the test class.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
rajesh4794
Highly Voted 2 years, 10 months ago
The Answer is B
upvoted 16 times
...
amerbearat
Highly Voted 2 years, 3 months ago
Should be B
upvoted 7 times
...
lorenac2
Most Recent 11 months, 1 week ago
Selected Answer: B
The answer is B. Answer A just moves the logic outside of the test class, but still runs the same amount of code. When you could do is use a TestDataFactory class marked with @IsTest and put that in the @TestSetup method, especially if more than one test class will be using the same data.
upvoted 3 times
...
Dean5555
1 year, 1 month ago
Selected Answer: B
B as levian explained
upvoted 2 times
...
levian
1 year, 1 month ago
Its B, because the problem is "many methods to create many records", if we use testSetup dont need to create many methods and the performance is increased. TestDataFactyory is used for reuse record creation in many classes, for example, create Account, Contact records, and reuse in many classes. But the question is not asking about reuse in other classes, so TestSetup its enough.
upvoted 2 times
...
ChiaSam
1 year, 5 months ago
Answer is A, as question is talking about improvement in slowness, B would not make it faster although a recommended way.
upvoted 1 times
...
singhkar
2 years, 5 months ago
The correct ans is B
upvoted 6 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...