dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 657 forks source link

dotnet.unitTests.runSettingsPath not working on mac #6656

Closed zhen8838 closed 8 months ago

zhen8838 commented 8 months ago

Type: Bug

Issue Description

when add the "dotnet.unitTests.runSettingsPath" in to settings.json, but the integrate test still can't load the runSetting file.

Steps to Reproduce

clone my repo, using vscode integrate to run or debug the UnitTest.

public class UnitTest
{
    [Fact]
    public void TestRunSettings()
    {
        Assert.Equal("ortools", System.Environment.GetEnvironmentVariable("SOLVER"));
    }
}

Expected Behavior

  1. using command line can pass the test
    dotnet test -s Sudoku.Tests/test.runsettings
  2. using the integrate test can pass the test with setting "dotnet.unitTests.runSettingsPath": "${workspaceFolder}/Sudoku.Tests/test.runsettings"

    Actual Behavior

  3. test passed when using command line.
  4. test failed when using integrate test.

    Logs

C# log

Post the output from Output-->C# here

C# LSP Trace Logs

Post the output from Output-->C# LSP Trace Logs here. Requires `dotnet.server.trace` to be set to `Trace`

Environment information

VSCode version: 1.84.2 C# Extension: 2.10.28 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 7.0.306 Commit: f500069cb7 Runtime Environment: OS Name: Mac OS X OS Version: 14.1 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/7.0.306/ Host: Version: 7.0.9 Architecture: arm64 Commit: 8e9a17b221 .NET SDKs installed: 7.0.306 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 7.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: x64 [/usr/local/share/dotnet/x64] registered at [/etc/dotnet/install_location_x64] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |autopep8|ms-python|2023.8.0|ms-python.autopep8-2023.8.0| |better-comments|aaron-bond|3.0.2|aaron-bond.better-comments-3.0.2| |change-case|wmaurer|1.0.0|wmaurer.change-case-1.0.0| |csdevkit|ms-dotnettools|1.0.14|ms-dotnettools.csdevkit-1.0.14-darwin-arm64| |csharp|ms-dotnettools|2.10.28|ms-dotnettools.csharp-2.10.28-darwin-arm64| |doxdocgen|cschlosser|1.4.0|cschlosser.doxdocgen-1.4.0| |file-icons|file-icons|1.1.0|file-icons.file-icons-1.1.0| |git-graph|mhutchie|1.30.0|mhutchie.git-graph-1.30.0| |gitlens|eamodio|14.4.1|eamodio.gitlens-14.4.1| |graphviz-interactive-preview|tintinweb|0.3.5|tintinweb.graphviz-interactive-preview-0.3.5| |hexeditor|ms-vscode|1.9.12|ms-vscode.hexeditor-1.9.12| |icons-carbon|antfu|0.2.6|antfu.icons-carbon-0.2.6| |increment-selection|albymor|0.2.0|albymor.increment-selection-0.2.0| |intellicode-api-usage-examples|VisualStudioExptTeam|0.2.8|visualstudioexptteam.intellicode-api-usage-examples-0.2.8| |isort|ms-python|2023.10.1|ms-python.isort-2023.10.1| |jupyter|ms-toolsai|2023.10.1003070148|ms-toolsai.jupyter-2023.10.1003070148-darwin-arm64| |jupyter-keymap|ms-toolsai|1.1.2|ms-toolsai.jupyter-keymap-1.1.2| |jupyter-renderers|ms-toolsai|1.0.17|ms-toolsai.jupyter-renderers-1.0.17| |material-theme|zhuangtongfa|3.16.2|zhuangtongfa.material-theme-3.16.2| |pdf|tomoki1207|1.2.2|tomoki1207.pdf-1.2.2| |python|ms-python|2023.20.0|ms-python.python-2023.20.0| |remote-containers|ms-vscode-remote|0.321.0|ms-vscode-remote.remote-containers-0.321.0| |remote-explorer|ms-vscode|0.4.1|ms-vscode.remote-explorer-0.4.1| |remote-ssh|ms-vscode-remote|0.107.0|ms-vscode-remote.remote-ssh-0.107.0| |remote-ssh-edit|ms-vscode-remote|0.86.0|ms-vscode-remote.remote-ssh-edit-0.86.0| |test-adapter-converter|ms-vscode|0.1.8|ms-vscode.test-adapter-converter-0.1.8| |todo-tree|Gruntfuggly|0.0.226|gruntfuggly.todo-tree-0.0.226| |vscode-custom-css|be5invis|7.2.1|be5invis.vscode-custom-css-7.2.1| |vscode-dotnet-runtime|ms-dotnettools|2.0.0|ms-dotnettools.vscode-dotnet-runtime-2.0.0| |vscode-github-actions|github|0.26.2|github.vscode-github-actions-0.26.2| |vscode-jupyter-cell-tags|ms-toolsai|0.1.8|ms-toolsai.vscode-jupyter-cell-tags-0.1.8| |vscode-jupyter-slideshow|ms-toolsai|0.1.5|ms-toolsai.vscode-jupyter-slideshow-0.1.5| |vscode-lldb|vadimcn|1.10.0|vadimcn.vscode-lldb-1.10.0| |vscode-mlir|llvm-vs-code-extensions|0.0.11|llvm-vs-code-extensions.vscode-mlir-0.0.11| |vscode-pylance|ms-python|2023.11.10|ms-python.vscode-pylance-2023.11.10| |vscode-test-explorer|hbenl|2.21.1|hbenl.vscode-test-explorer-2.21.1| |vscode-wakatime|WakaTime|24.4.0|wakatime.vscode-wakatime-24.4.0| |vscode-yaml|redhat|1.14.0|redhat.vscode-yaml-1.14.0| |vscodeintellicode|VisualStudioExptTeam|1.2.30|visualstudioexptteam.vscodeintellicode-1.2.30| |vscodeintellicode-csharp|ms-dotnettools|0.1.26|ms-dotnettools.vscodeintellicode-csharp-0.1.26-darwin-arm64| |vsliveshare|ms-vsliveshare|1.0.5892|ms-vsliveshare.vsliveshare-1.0.5892|;

Extension version: 2.10.28 VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:52:57.054Z) OS version: Darwin arm64 23.1.0 Modes: Remote OS version: Linux x64 5.4.0-42-generic

System Info |Item|Value| |---|---| |CPUs|Apple M2 Pro (12 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|1, 1, 1| |Memory (System)|32.00GB (2.31GB free)| |Process Argv|--crash-reporter-id efe2778d-60f4-4b14-91c3-5938f30e4c19| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: 3990| |OS|Linux x64 5.4.0-42-generic| |CPUs|AMD EPYC 7T83 64-Core Processor (256 x 1499)| |Memory (System)|2003.97GB (1862.59GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263:30880072 vsclangdf:30486550 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 89544117:30613380 a9j8j154:30646983 showlangstatbar:30737416 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30869155 dsvsc013:30795093 dsvsc014:30804076 dsvsc015:30845448 pythontestfixt:30871694 pythonregdiag2:30871582 pyreplss2:30886141 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:30885897 pythontbext0:30879054 dsvsc016:30886110 dsvsc017cf:30886113 dsvsc018cf:30886115 aa_t_chat:30882232 ```
zhen8838 commented 8 months ago

maybe have a similar bug like issuse #5131

dibarbet commented 8 months ago

The dotnet.unitTests.runSettingsPath only works for C# standalone (without C# devkit installed). We do support paths relative to the workspace, but you don't need the ${workspaceFolder} parameter. This should work (with the C# extension only, not with Devkit)

"dotnet.unitTests.runSettingsPath": "Sudoku.Tests/test.runsettings"

However the C# extension standalone doesn't implement a test explorer, so using devkit is generally better. But I do not know if devkit supports specifying a .runsettings file. @peterwald do you know?

dibarbet commented 8 months ago

Ah it looks like devkit does not support a .runsettings file yet, see https://github.com/microsoft/vscode-dotnettools/issues/156

So for now, no action here on the C# extension side. dotnet.unitTests.runSettingsPath should work with the path I gave above if devkit is uninstalled or disabled. For devkit support for this feature, please use the issue I linked to track / upvote.

peterwald commented 8 months ago

@dibarbet That is correct. C# Dev Kit does not yet support custom runSettings. It is on the short list, however.

sabahtalateh commented 8 months ago

@dibarbet Is there a way to run tests from UI with C# extension? I removed devkit and test explorer not detecting tests now

dibarbet commented 8 months ago

@dibarbet Is there a way to run tests from UI with C# extension? I removed devkit and test explorer not detecting tests now

Unfortunately not, we don't integrate with the test explorer. The only way is via the run / debug tests code lens items image