question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run All Tests fails in namespaced scratch org

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
NightBijoucommented, Jan 29, 2021

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.

2reactions
andrey-tsvor-vrpcommented, Jan 29, 2021

Hi @NightBijou It helped me. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Run test' fails in namespaced scratch org · Issue #2865 - GitHub
Running a test from the command line is OK. Steps To Reproduce: Create a scratch org with a namespace. Create an Apex test...
Read more >
RoseSilverSoftware / IlluminatedCloud / issues / #1306 - Can't run ...
Can't run tests in scratch org with namespace. ... I have a namespace 'c_fflib' and I can't run tests in this namespace for...
Read more >
How to test DX-namespaced package in regular sandbox
My tester don't want to use scratch orgs for testing, so we deploy our code (by done feature) using metadata convert into a...
Read more >
Second Generation(2GP) Package installation fails in Scratch ...
Summary Second Generation(2GP) Package installation fails in a scratch Org with no namespace or different namespace. It throws below error :
Read more >
Create a Namespaced Scratch Org - Salesforce DX for ISVs
Create a Namespaced Scratch Org. In this exercise, you will… Add your Packaging Org's namespace to sfdx-project.json; Use the CLI to create ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found