Skip to content

dotnet.unitTests.runSettingsPath is not passed to the test runner when running individual tests from Test Explorer #3171

@agnieszkakucharczyk

Description

@agnieszkakucharczyk

Describe the Issue

When running individual tests or test suites from the Test Explorer in C# Dev Kit, the .runsettings file configured via dotnet.unitTests.runSettingsPath is not passed to the test runner. As a result, TestContext.Parameters is empty and any test that reads parameters from fails with System.InvalidOperationException.

The same project works correctly in:

  • Full Visual Studio — runsettings are passed and TestContext.Parameters is populated
  • dotnet test via terminal with explicit --settings flag — works as expected

Steps To Reproduce

Steps to Reproduce

  1. Configure dotnet.unitTests.runSettingsPath in VS Code user settings (or workspace settings) pointing to a valid .runsettings file
  2. The .runsettings file contains a section, e.g.:
<TestRunParameters>
    <Parameter name="Url" value="https://my-app.example.com" />
</TestRunParameters>
  1. In test code, read the parameter:
    private readonly string _url = TestContext.Parameters["Url"] ?? throw new InvalidOperationException("Required test parameter 'Url' is missing.");

  2. Run the test from Test Explorer (click the run button next to the test)

Expected Behavior

The test runner receives the runsettings file. TestContext.Parameters["Url"] returns "https://my-app.example.com".

Environment Information

VS Code | 1.122.1 -- | -- C# Dev Kit | 3.20.199 C# extension | 2.140.8 .NET SDK | 10.0.300 OS | Windows 11 Test framework | NUnit 4.1.0 + NUnit3TestAdapter 4.5.0

Metadata

Metadata

Assignees

Labels

area-testTest discovery, execution, debuggingbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions