salesforcedx-vscode: Run All Tests fails in namespaced scratch org

Summary

I’m developing on a managed package in a namespaced scratch org. When I try to run all of the Apex tests in a particular test class from the IDE with the “Run All Tests” link that appears at the top, it fails, saying “Unable to invoke any tests…This class name’s value is invalid.” Running a single test with the “Run Test” link above that specific method works fine. Running all the tests by doing “Invoke Apex Tests” from the command menu also works fine.

The problem appears to be that the namespace is prepended unnecessarily. If my namespace is “Test,” and my class is called “TestClass,” running all of the tests with the “Run All Tests” link produces a command like: sfdx force:apex:test:run --tests Test.TestClass When it fails, the error message says “This class name’s value is invalid: Test.Test,” which indicates that the namespace is being duplicated. If I modify the command to remove the namespace, as below, it works correctly: sfdx force:apex:test:run --tests TestClass The “Invoke Apex Tests” menu item appears to use a different flag, which produces this (also correct) command: sfdx force:apex:test:run --classnames TestClass

Steps To Reproduce:

  1. Create a scratch org with a namespace
  2. Create an Apex test class with some tests
  3. Click the “Run All Tests” link that should appear in the editor above the class definition

Expected result

All tests in the class should run

Actual result

No tests run. An error message is returned about a missing class / invalid class name.

VS Code Version: 1.34.0

SFDX CLI Version: sfdx-cli/7.6.0-28071a499b darwin-x64 node-v10.15.3

OS and version: macOS Mojave 10.14.5

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Hello @lcampos, same over here. I found a workaround though, maybe you can try this too: Go to the Salesforce settings in VS Code and set the option salesforcedx-vscode-core.experimental.useApexLibrary to false.

image

Maybe this can tide you over until this is fixed.

Hi @NightBijou It helped me. Thanks!

@ajw725 @NightBijou thanks for all the feedback and details. We were able to replicate this issue last night and we’re currently working on a fix. The issue is in the CLI command (force:apex:test:run) and caused by a bug in the way we evaluate the namespace. This is why it sometimes removes or duplicates the namespace as part of the fullname of a class. We’ll let you know once the fix is checked in and ready to be published. cc @brpowell @ntotten

I can’t seem to find that setting in my version: sfdx-cli/7.114.0 win32-x64 node-v14.17.0. Any ideas?