PDI practice question 25 of 30
A developer created a trigger on the Account object and wants to test if the trigger is properly bulkified. The developer team decided that the trigger should be tested with 200 account records with unique names. What two things should be done to create the test data within the unit test with the least amount of code? Choose 2 answers
Full set: 201 questionsTo test for bulkification with 200 unique records using the least amount of Apex code, the most efficient method is to use a static resource. A developer can create a CSV file containing the 200 unique Account records and upload it as a static resource. The Test.loadData() method is then used within the test class to populate the test context with these records from the static resource. This approach requires only a single line of Apex code (Test.loadData(...)) to create all 200 records, which is significantly less code than writing a loop to generate them programmatically.
A. Use the @isTest (seeAllData=true) annotation in the test class. This annotation does not create test data; it grants access to existing organization data, which violates test data isolation principles and is not a recommended practice.
B. Use the @isTest (isParallel=true) annotation in the test class. This annotation is used to enable parallel test execution for performance optimization. It has no function related to the creation or management of test data.
1. Apex Developer Guide, "Loading Test Data":
Section: Test.loadData Method
Content: "The Test.loadData method enables you to populate your test methods with data from a static resource... The static resource must be a CSV file... Using this method, you can create many records with only one method call, which is very useful for creating test data." This directly supports using a static resource (C) with the Test.loadData method (D).
2. Apex Developer Guide, "isTest Annotation":
Section: seeAllData=true Parameter
Content: "The seeAllData=true annotation is used to grant test classes and individual test methods access to all data in the organization, including existing data and data created in the test. However, we don’t recommend using this annotation... it makes tests less robust and might fail when run in different environments." This confirms why option A is incorrect and against best practices.
3. Apex Developer Guide, "Running Unit Test Methods":
Section: isParallel=true Parameter
Content: "Use the @isTest(isParallel=true) annotation to indicate that test classes can run in parallel. The default is to run tests serially." This confirms that option B is related to test execution performance, not data creation.
Keep practicing
Take the free PDI practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PDI practice questions
- Question 1What can be used to override the Account's standard Edit button for Lightning Experience?
- Question 4Universal Containers (UC) wants to lower its shipping cost while making the shipping proc…
- Question 5A developer has an integer variable called maxAttempts. The developer needs to ensure tha…
- Question 7Universal Containers wants to back up all of the data and attachments in its Salesforce o…
- Question 8Universal Containers hires a developer to build a custom search page to help users find t…
- Question 9As part of new feature development, a developer is asked to build a responsive applicatio…
