How to run C# unit test
See original GitHub issueIssue Description
Not able to debug C# unit test on Mac As VScode is the only way to debug dotnet core C# project on Mac, can you help take a look? Thanks!
Steps to Reproduce
1.download test solution: https://github.com/NuGet/NuGet.Client/tree/dev-hengliu-6enableMacAddCert 2.make sure you have dotnet SDK 3.0 installed 3.edit settings.json according to https://github.com/OmniSharp/omnisharp-vscode/wiki/How-to-run-and-debug-unit-tests 4.in settings, set following to true: csharp.referencesCodeLens.enabled csharp.testsCodeLens.enabled 5.edit launch.json as following: { “name”: “.NET Core Launch (console)”, “type”: “coreclr”, “request”: “launch”, “preLaunchTask”: “build”, “program”: “${workspaceFolder}/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/bin/Debug/netcoreapp3.0/NuGet.Packaging.FuncTest.dll”, “args”: [], “cwd”: “${workspaceFolder}/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest”, “console”: “internalConsole”, “stopAtEntry”: true, “requireExactSource”: false } 6. open ./test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/SignatureTrustAndValidityVerificationProviderTests.cs, set break point at any test cases
Expected Behavior
“run test”, “debug test” should displayed as the https://github.com/OmniSharp/omnisharp-vscode/wiki/How-to-run-and-debug-unit-tests
Actual Behavior
no “run test”, “debug test” displayed.
And I don’t know if this is the only way to debug C# unit tests. It would be great if there is any work around.
By the way, I could run dotnet test to test ./test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/NuGet.Packaging.FuncTest.csproj
If I click debug, the following logs displayed:
Logs
`------------------------------------------------------------------- You may only use the Microsoft .NET Core Debugger (vsdbg) with Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you develop and test your applications.
Loaded ‘/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Private.CoreLib.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled. Breakpoint warning: No executable code of the debugger’s target code type is associated with this line. Possible causes include: conditional compilation, compiler optimizations, or the target architecture of this line is not supported by the current debugger code type. - /Users/heng/repos/NuGet.Client/NuGet.Client/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/SigningTests/PrimarySignatureTests.cs:214 Loaded ‘/Users/heng/repos/NuGet.Client/NuGet.Client/test/NuGet.Core.FuncTests/NuGet.Packaging.FuncTest/bin/Debug/netcoreapp3.0/NuGet.Packaging.FuncTest.dll’. Symbols loaded. Loaded ‘/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.0/System.Runtime.dll’. Skipped loading symbols. Module is optimized and the debugger option ‘Just My Code’ is enabled. The program ‘[23195] NuGet.Packaging.FuncTest.dll’ has exited with code 0 (0x0).`
OmniSharp log
C# log
Environment information
VSCode version: 1.39.2 C# Extension: 1.21.5
Mono Information
OmniSharp using global mono :6.4.0Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26Runtime Environment: OS Name: Mac OS X OS Version: 10.14 OS Platform: Darwin RID: osx.10.14-x64 Base Path: /usr/local/share/dotnet/sdk/3.0.100/
Host (useful for support): Version: 3.0.0 Commit: 7d57652f33
.NET Core SDKs installed: 2.1.701 [/usr/local/share/dotnet/sdk] 3.0.100-preview8-013656 [/usr/local/share/dotnet/sdk] 3.0.100 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview8-28405-07 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
Extension | Author | Version |
---|---|---|
csharp | ms-vscode | 1.21.5 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Thanks for filing. There appear to be some general issues with test discovery, and there could stand to be some more deliberate work around the design for test discovery and execution in general.
Is this bug not fixed yet?