Courseiva

SF-PD2 Testing, Debugging, and Deployment Practice Question

A developer needs to run a single Apex test method named testBulkInsert in a class named AccountServiceTest against a sandbox org and view the results from the command line. Which Salesforce CLI command should the developer use?

⚠ Common exam trap

Many exam-takers confuse sf apex run (anonymous Apex) with sf apex run test (Apex test execution), which are distinct commands.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

sf apex run test --tests AccountServiceTest.testBulkInsert --target-org mySandbox --result-format human

The sf apex run test command is the current Salesforce CLI command for executing Apex tests, and its --tests flag accepts a fully qualified ClassName.methodName to target a single method. Adding --result-format human makes the output readable in the terminal, which matches the developer's goal of running one test and viewing results from the command line.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    sf apex run test --tests AccountServiceTest.testBulkInsert --target-org mySandbox --result-format human

    Why this is correct

    The sf apex run test command executes Apex tests against the specified org. Using --tests with the fully qualified ClassName.methodName runs only that test method, and --result-format human prints readable results to the terminal. This is the current CLI syntax for running a targeted Apex test from the command line.

  • ✗

    sf project deploy start --test-level RunSpecifiedTests --tests AccountServiceTest.testBulkInsert

    Why it's wrong here

    This command deploys metadata and can run specified tests as part of a deployment, but it is not the command for running tests against an already-deployed class. It would attempt a deployment, which is unnecessary and potentially disruptive when the goal is simply to execute an existing test.

  • ✗

    sf apex get test --tests AccountServiceTest.testBulkInsert --target-org mySandbox

    Why it's wrong here

    sf apex get test retrieves previously run test results from the org; it does not execute tests. Using it would return historical results rather than running the specified method, so it does not satisfy the requirement to run the test and view fresh output.

  • ✗

    sf apex run --file AccountServiceTest.cls --target-org mySandbox

    Why it's wrong here

    sf apex run executes anonymous Apex from a file or standard input; it does not run test methods and does not accept a class file as a test selector. It would attempt to execute the class body as anonymous Apex, which is not the intended way to run a specific test method.

About these practice questions

Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Salesforce exam blueprint

This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.