Question 1 of 30
A developer is tasked with writing unit tests for a new Apex class that processes customer orders. The class includes a method that calculates the total price of an order based on the quantity of items and their individual prices. The developer needs to ensure that the method handles various scenarios, including edge cases such as zero quantity and negative prices. Which of the following strategies should the developer prioritize to ensure comprehensive unit testing of this method?
Create multiple test methods that cover different scenarios, including valid inputs, edge cases, and invalid inputs, while asserting expected outcomes for each case.
Write a single test method that tests the method with a variety of inputs in a single execution, focusing only on valid scenarios.
Use mock objects to simulate the behavior of external services that provide item prices, ensuring that the unit tests are isolated from external dependencies.
Rely on the built-in Salesforce testing framework to automatically generate test cases based on the method's logic without manual intervention.

Preparing for SalesForce CRT-450 Certified Platform Developer I? Now land the interview.

73% of qualified candidates get rejected because of weak resumes. Build an ATS-optimized, recruiter-ready resume in under 5 minutes - free to start.

Build My Resume Free