Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Run Test" action hanging #6131

Open
joshua-nicholson opened this issue Mar 7, 2025 · 18 comments
Open

"Run Test" action hanging #6131

joshua-nicholson opened this issue Mar 7, 2025 · 18 comments

Comments

@joshua-nicholson
Copy link

joshua-nicholson commented Mar 7, 2025

Summary

If I click "Run Test" on any of my tests, I get a dialogue box that says "Running SFDX: Running Apex tests". This continues indefinitely and the test is never executed. I checked Salesforce and it does not show a test run was ever attempted. If I manually execute the test via the CLI it works fine.

Steps To Reproduce:

  1. Click "Run Test" above any test method.

Expected result

Test should execute in a timely manner.

Actual result

Test execution is never attempted

Additional information

Salesforce Extension Version in VS Code: 63.2.3

Salesforce CLI Version: @salesforce/cli/2.78.3 darwin-arm64 node-v22.13.0

OS and version: macOS Sonoma 14.7.3 (23H417)

VS Code version: 1.98.0

Most recent version of the extensions where this was working: Unknown

@svc-idee-bot
Copy link
Collaborator

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@svc-idee-bot
Copy link
Collaborator

Hello @joshua-nicholson 👋 It looks like you didn't provide all the required basic info in your issue.

If you haven't already, please provide the following info:
Salesforce Extension Version in VS Code:
Salesforce CLI Version:
OS and version:
VS Code version:
Most recent version of the extensions where this was working:

Here's an example of a set of required info that will pass the validation:
Salesforce Extension Version in VS Code: 60.13.0
Salesforce CLI Version: @salesforce/cli/2.42.6 darwin-arm64 node-v18.18.2
OS and version: MacOS Sonoma 14.5
VS Code version: 1.89.1
Most recent version of the extensions where this was working: 60.11.0

A few more things to check:

  • Make sure you've provided detailed steps to reproduce your issue, as well as all error messages that you see.
    • A repository that clearly demonstrates the bug is ideal.
    • Error messages can be found in the Problems Tab, Output Tab, and from running Developer: Toggle Developer Tools in the command palette.
  • Make sure you've installed the latest version of the Salesforce Extension Pack for VSCode. (docs)
  • Search GitHub for existing related issues.

Thank you!

@joshua-nicholson
Copy link
Author

There were no error messages produced in any of the output panels and I am not sure what version I was on when this was working previously.

@CristiCanizales
Copy link
Contributor

Hello @joshua-nicholson, can you confirm Apex extension is activated? You can verify it if you run Developer: Show Running extensions from the command palette (CMD + Shift + P).
Also, when you checked the output panel, did you select from the dropdown both Apex and Apex Language Server options to verify the logs?
Last but not least, do you have Java installed and JAVA_HOME env var set?
Thanks in advance!

@joshua-nicholson
Copy link
Author

joshua-nicholson commented Mar 7, 2025

Hi @CristiCanizales thanks for the quick response.

I verified the Apex extension is running. My JAVA_HOME env var was somehow unset, I corrected this but I'm still seeing the same behavior.

Here is the JDK I'm using:

openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode)

Both the Apex and Apex Language Server aren't giving me any relevant errors that I can see. Apex simply outputs:

12:24:33.577 Starting SFDX: Run Apex Tests

The Apex Language Server shows the extensions starting up.

12:24:24.219 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning built-in Apex types.
12:24:24.220 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Collecting built-in standard types from jar
12:24:24.372 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Done collecting built-in standard types from jar
12:24:24.372 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning Apex Standard Library.
12:24:24.428 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Done scanning Apex Standard Library.
12:24:24.429 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Starting ApexIndexer.
12:24:24.429 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Start indexer.
12:24:24.432 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types.
12:24:24.432 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning workspace source.
12:24:24.476 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Building change list.
12:24:24.514 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: No indexing changes found
12:24:24.547 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: StandardObjects: 19
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: CustomObjects: 0
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ApexFiles: 213
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: ErrorFiles: 167
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Total Memory (MB): 160
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Used Memory (MB): 110
12:24:24.548 [ApexIndexer STARTING] INFO  a.jorje.lsp.impl.index.ApexIndexer - ApexIndexer: Scanning user-defined types took 85 ms.
12:24:24.549 [Apex Prelude Service STARTING] INFO  a.j.l.i.s.ApexPreludeManagedService - Scanning built-in and system Apex types took 345 ms.
Mar 07, 2025 12:24:24 PM apex.jorje.parser.impl.BaseApexLexer dedupe
INFO: Deduped array ApexLexer.DFA22_transition. Found 7075545 shorts which is 13MB not including array overhead. Removed 6418975 shorts which is 12MB not counting array overhead. Took 3 ms.
Mar 07, 2025 12:24:25 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 2
Mar 07, 2025 12:24:25 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 3
Mar 07, 2025 12:24:30 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 12```

@CristiCanizales
Copy link
Contributor

Thanks for providing the details. Just to make sure, are you successfully connected to the org you want to run the tests from? If so, is it your default org? And your local project is up to date with your org?

@joshua-nicholson
Copy link
Author

joshua-nicholson commented Mar 7, 2025

Yes I was able to successfully authorize my org and set it as the default. Could you explain what you mean by my local project being up to date with the org specifically? I believe it should be, our Apex code is tracked in version control and I have the latest changes, additionally the org I'm connecting to is a developer org I just created from production.

@CristiCanizales
Copy link
Contributor

I mean if the apex class you want to use to run the test + the test are deployed

@joshua-nicholson
Copy link
Author

Yes both of these have been deployed.

@CristiCanizales
Copy link
Contributor

Have you tried running the tests from the sidebar testing panel?

Image

@joshua-nicholson
Copy link
Author

This is giving me the same issue.

@CristiCanizales
Copy link
Contributor

public class HelloWorld {
    public static void sayHello() {
        System.debug('Hello, world!');
    }
}

@IsTest
public class HelloWorldTest {
    @IsTest
    static void testSayHello() {
        HelloWorld.sayHello();
        System.assert(true, 'Hello, world! test passed');
    }
}

Would you mind creating those two apex classes in your project, deploying to the org and running the test from the 2nd one to check if it works with that?

@joshua-nicholson
Copy link
Author

I'm still seeing the same behavior with this test class.

@peternhale
Copy link
Contributor

@joshua-nicholson Would you mind running the tests again for me with debug enabled?

In workspace settings search for SF_LOG_LEVEL and change the setting to debug
Reload the IDE
Run the Apex tests from Testing sidebar, wait a minute or so and the shutdown the IDE

In folder $HOME/.sf you should see log files similar to sf-2025-03-11.log. Zip the most recent and get it back to us so we can have a look.

Could you also provide the org Id on which you are using to run tests.

@peternhale
Copy link
Contributor

peternhale commented Mar 11, 2025

@joshua-nicholson thanks for the log. I can see that the test run is trying to establish a connection to your org, but I do not see a return from that request.

So I have a comparison logs, run the tests using sf bug but using the doctor command sf doctor -c 'apex run test ...'. This command will produce a number output artifacts. Please return those.

Is the target org a scratch org?

@joshua-nicholson
Copy link
Author

joshua-nicholson commented Mar 11, 2025

The target org is a developer org created from my production org.

I think this command turned up the source of my issue.

* Cannot reach https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-win32-x64-buildmanifest - potential network configuration error, check proxies, firewalls, environment variables.

What's strange is I can run commands directly for testing, for example.

sfdx force:apex:test:run --tests HelloWorld.HelloWorldTest --synchronous

This runs with no issues, it's just the way the extensions provides to run tests that isn't working. Is there some way I can manually download the manifest? Proxies seem to be working otherwise.

@peternhale
Copy link
Contributor

@joshua-nicholson sorry if I raised your blood pressure with my earlier message challenging the version you are using.

Some suggestions to try:

Since the command works in the terminal but fails within VSCode, the issue likely involves how VSCode handles network configurations, environment variables, or how the extension spawns the process. Here are some things to check:

  • Check VSCode Proxy Settings

Open VSCode settings (Cmd+Shift+P → "Preferences: Open Settings (UI)").
Search for proxy. Ensure that http.proxy and https.proxy are correctly configured if you are behind a proxy.
Try setting "http.proxySupport": "off" in your settings to see if it bypasses the issue.

  • Check Environment Variables in VSCode

Run Developer: Open Environment Variables in the command palette to compare with your terminal's environment.
If HTTPS_PROXY or HTTP_PROXY are different, try setting them explicitly in your settings.json or launch environment.
Check VSCode's Integrated Terminal

  • Open the VSCode terminal (`Cmd+``) and run the command there.

If it works there, the issue might be related to how VSCode extensions spawn subprocesses.
Check Salesforce CLI in VSCode

Run sf env list to check if the expected authentication and environment are detected.

  • Try Running VSCode with System Environment

Close VSCode and restart it using the terminal with code . to ensure it inherits the correct environment variables.

  • Check Firewall & Network Settings

If you're using a corporate network, ensure that VSCode is not blocked from accessing external resources.
Check if NODE_TLS_REJECT_UNAUTHORIZED=0 helps, but only for debugging, as this disables SSL verification.

@joshua-nicholson
Copy link
Author

No worries, I thought you saw something in the logs that indicated I was using an earlier version than I listed so I thought that might be an avenue to investigate at first. I'll give this a try, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants