Which two statements are accurate about why Mock objects are needed when writing test classes?
Choose 2 answers
A.
Mock can also be used on the classes that extend the batchable interface to bypass the batch jobs.
B.
Using a Mock allows the test class to bypass the dependencies of other objects, methods, state, or behaviors. Therefore, the developer has total control of his own code.
C.
Some methods are invoking long running processes, using Mock is a shortcut of bypassing the long executions.
D.
A Mock is needed whenever the code makes an HTTP callout.
Mock objects are needed when writing test classes to simulate the behavior of real objects or external services that are not available or accessible in the test context. Using a Mock allows the test class to bypass the dependencies of other objects, methods, state, or behaviors, and therefore, the developer has total control of their own code. This is especially useful when the code makes an HTTP callout, as the test class cannot actually call an external web service. A Mock is needed to provide a fake response for the HTTP callout. A Mock is not needed for the classes that extend the batchable interface, as the test class can use the Test.startTest and Test.stopTest methods to execute the batch jobs synchronously. A Mock is not a shortcut for bypassing long running processes, as the test class should still test the functionality and performance of the code.
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit