nerdexam
Salesforce

PDII · Question #6

An Apex class does not achieve expected code coverage. The testSetup method explicitly calls a method in the Apex class. How can the developer generate the code coverage?

The correct answer is B. Call the Apex class method from a testMethod instead of the testSetup method. See the full explanation below for the reasoning.

Question

An Apex class does not achieve expected code coverage. The testSetup method explicitly calls a method in the Apex class. How can the developer generate the code coverage?

Options

  • AVerify the user has permissions passing a user into System.runAs().
  • BCall the Apex class method from a testMethod instead of the testSetup method.
  • CAdd @testVisible to the method in the class the developer is testing.
  • DUse system.assert() in testSetup to verify the values are being returned.

How the community answered

(16 responses)
  • A
    13% (2)
  • B
    81% (13)
  • C
    6% (1)

Community Discussion

No community discussion yet for this question.

Full PDII Practice