QuestionQ15

VerifiedTest Automation Tools

A developer on the Universal Containers team has created a test class for a method that involves a web-service callout. In the test class, the developer should load test data, create an instance of the Mock object, set Test.setMock() to that Mock object, call startTest(), execute the code that performs the callout, call stopTest(), and compare the result against expectations. Unfortunately, the developer omitted the Test.setMock() step.

What happens when the developer runs this test class?

Explanation

Apex test methods cannot make real web-service callouts. Test.setMock() supplies the registered mock response for the callout; without it, executing the callout in the test raises the exception that methods defined as TestMethod do not support web-service callouts.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!