4

At some point in the last week I found that I can no longer see the following prompts at the top of already working unit tests in VS Code

  • Run All Tests
  • Run Test | Debug Test

No "Run All Tests" or "Run Test"

While this is absolutely a nice-to-have, it does affect my workflow quite a bit. I've tried removing and setting up a fresh WSL instance using the generic Ubuntu installation.

VS Code Info:

  • Version: 1.78.0 (user setup)
  • Commit: 252e5463d60e63238250799aef7375787f68b4ee
  • Date: 2023-05-03T20:09:00.748Z
  • Electron: 22.4.8
  • Chromium: 108.0.5359.215
  • Node.js: 16.17.1
  • V8: 10.8.168.25-electron.0
  • OS: Windows_NT x64 10.0.19045
  • Sandboxed: No

I have the latest versions of the extensions included in the:

  • Salesforce Extension Pack
  • Salesforce Extension Pack (Expanded)

I've installed sfdx through npm. I have tried using both of the following packages

  • sfdx-cli
  • @salesforce/cli - Currently in use

I found this post StackExchange: Unable to Run Tests from VSCode which suggests disabling "Use Apex Library for Apex CLI Commands, however this option is not visible in my preferences to try toggling.

My npm list output:

├── @lwc/[email protected]
├── @prettier/[email protected]
├── @salesforce/[email protected]
├── @salesforce/[email protected]
├── @salesforce/[email protected]
├── @salesforce/[email protected]
├── @salesforce/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Java Info

openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 17.0.6+10-Ubuntu-0ubuntu122.04, mixed mode, sharing)

When clicking on the "Testing" tab in VS Code, there are no longer any unit test classes or functions listed there.

I've also tried setting things up with the bare minimum on a fresh install of Windows 11 using WSL2 & Ubuntu, with the same result.

Has anyone else experienced this or have any suggestions I could try? Any help suggestions greatly appreciated.

4 Answers 4

8

So I spent most of the past weekend cross checking what the settings are on my work laptop, and the only difference was the VS Code version and the fact that there is nothing set for: "salesforcedx-vscode-apex.java.home": in settings.

Running which java gives me the same output on my personal machines and work machine: /usr/bin/java. This was set as my java.home previously before it stopped working.


I have fixed the issue and I feel more than a bit silly:

"salesforcedx-vscode-apex.java.home": "/usr/lib/jvm/java-17-openjdk-amd64"

enter image description here

2
  • I had the same problem on Windows 10. For me this setting had been filled, with C:\\Program Files\\java-1.8.0. Also: the xml.java.home setting was empty. I filled both of these with C:\\Program Files\\Zulu\\zulu-17 (yes, backslash must be escaped) and now I can run unit tests again in VS! Commented Sep 20, 2023 at 10:28
  • This answer worked for me. One caveat, as of 10/2023, VS code is only compatible with Java 11 and 17. I had 21 installed and had to install 17. On MacOS I used the following file path: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home Commented Oct 25, 2023 at 17:12
1

I had the "Run Test" and "Run All Tests" tags disappear because the Salesforcedx-vscode-apex › Java: Memory was too low for an Org with a lot of Apex.

Increasing the Memory size to avoided the Out-Of-Memory-Exception during start up and fixed the issue

Salesforcedx-vscode-apex › Java: Memory

Another issue that appears to happen when updating the JDK or after refreshing our Test Org from Production, is corruption of the Tools DB in the apex.db file. Kudos to Dunks182 for his github comment https://github.com/forcedotcom/salesforcedx-vscode/issues/5251#issuecomment-1848425889.

On Mac, exit VS Code, then run the following command, where PROJECT_DIR is your Salesforce Project directory and SF_RELEASE is the numbered release folder)

rm -rf PROJECT_DIR/.sfdx/tools/SF_RELEASE

For example:

rm -rf  my_sfdx_repo/.sfdx/tools/246

Restart VS Code and it'll recreate the tools directory.

0

The official instructions to fix this can be found here https://developer.salesforce.com/tools/vscode/en/vscode-desktop/java-setup

0

salesforcedx-vscode-apex.java.home (VSCode) = Java Path (Panel de control).

  1. En panel de control buscar "Java".
  2. Copiar path (imagen)
  3. Pegar esa ruta en VSCode salesforcedx-vscode-apex.java.home (doble barra)
  4. Reiniciar VSCode. ¡Recordar!: autorizar org y desplegar (deploy source to org).

Java Path (Panel de Control) Java Path (VS Code)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .