Search code examples
salesforceapexapex-code

Command 'SFDX: Run Apex Tests' resulted in an error (command 'sfdx.force.apex.test.run' not found)


I am learning Salesforce Apex development by taking a trailhead tutorial.

Tutorial: Find and Fix Bugs with Apex Replay Debugger

I followed the tutorial along and got the following error when I try to call "SFDX: Run Apex Tests" in Visual Studio Code.

Command 'SFDX: Run Apex Tests' resulted in an error (command 'sfdx.force.apex.test.run' not found)

enter image description here

enter image description here

I am able to run the tests in a terminal by the way.

enter image description here

Does anyone know how to fix this error?

Thanks in advance.


Added on 2021/11/30

I wonder if it has anything to do with the M1 chip.

My environment:

  • MacBook Pro (13-inch, M1, 2020)
  • macOS Big Sur

Solution

  • Let me answer my own question.

    Everything works fine after I added Java home setting in setting.json of VS Code.

    "salesforcedx-vscode-apex.java.home": "/opt/homebrew/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home",