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

Fix run tests on older versions of the SDK #69375

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Aug 4, 2023

Resolves dotnet/vscode-csharp#6022

There are two parts to this.

b9a4f2b is not the actual bug, however it was preventing me from finding the actual bug. Essentially we were not respecting the user's global.json configured for the workspace because we ran dotnet --info outside of the project. This meant we always used whatever the machine default dotnet value was and the global.json was ignored.

f46a316 Fixes the actual issue - the vstest console included in older SDKs (e.g. .net6) will throw if we pass a null run settings value to the API. The fix is to pass an empty run settings value instead.

Before:

Starting test discovery
Logging TestHost Diagnostics in file: c:\Users\WDAGUtilityAccount\AppData\Roaming\Code\logs\20230803T165938\window1\exthost\ms-dotnettools.csharp\testLogs\vsTestLogs.host.23-08-03_18-01-59_40586_9.txt
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 6.0.20)
[xUnit.net 00:00:00.28]   Discovering: UnitTests
[xUnit.net 00:00:00.31]   Discovered:  UnitTests
Found 1 tests in 851ms

Starting test run
Test run error: System.Exception: Value cannot be null.
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.UpdateRunSettingsIfRequired(String runsettingsXml, IList`1 sources, IBaseTestEventsRegistrar registrar, String& updatedRunSettingsXml, IDictionary`2& sourceToArchitectureMap, IDictionary`2& sourceToFrameworkMap)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.TestPlatformHelpers.TestRequestManager.RunTests(TestRunRequestPayload testRunRequestPayload, ITestHostLauncher3 testHostLauncher, ITestRunEventsRegistrar testRunEventsRegistrar, ProtocolConfig protocolConfig)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.<>c__DisplayClass23_0.<StartTestRun>b__0()

After

Starting test discovery
Logging TestHost Diagnostics in file: c:\Users\WDAGUtilityAccount\AppData\Roaming\Code\logs\20230803T165938\window1\exthost\ms-dotnettools.csharp\testLogs\vsTestLogs.host.23-08-03_18-06-35_59571_9.txt
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.3+1b45f5407b (64-bit .NET 6.0.20)
[xUnit.net 00:00:00.20]   Discovering: UnitTests
[xUnit.net 00:00:00.22]   Discovered:  UnitTests
Found 1 tests in 693ms

Starting test run
[Passed] UnitTests.UnitTest1.Test1
==== Summary ====
Passed!  - Failed:    0, Passed:    1, Skipped:    0, Total:    1, Duration: 237ms

…ing in the correct SDK for the vstest console
@dibarbet dibarbet requested a review from a team as a code owner August 4, 2023 01:06
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 4, 2023
@dibarbet dibarbet merged commit 0eb8b23 into dotnet:main Aug 4, 2023
@dibarbet dibarbet deleted the fix_run_tests branch August 4, 2023 20:19
@ghost ghost added this to the Next milestone Aug 4, 2023
@KPGDL
Copy link

KPGDL commented Aug 7, 2023

How to workaround this without waiting for fix?

@dibarbet
Copy link
Member Author

dibarbet commented Aug 7, 2023

How to workaround this without waiting for fix?

For now, either downgrade the extension or set the flag dotnet.server.useOmnisharp and reload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot run or debug xunit tests from CodeLens
4 participants