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.

How to run C# unit test

See original GitHub issue

Issue 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

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.39.2 C# Extension: 1.21.5

Mono Information OmniSharp using global mono :6.4.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26

Runtime 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:open
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cartermpcommented, Apr 14, 2020

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.

0reactions
jcbritobrcommented, Nov 1, 2020

Is this bug not fixed yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to write unit tests in plain C? - Stack Overflow
Unit testing only requires "cut-planes" or boundaries at which testing can be done. It is quite straightforward to test C functions which do ......
Read more >
C# unit test tutorial - Visual Studio (Windows) - Microsoft Learn
Build and run the test · On the Build menu, choose Build Solution (or press Ctrl + SHIFT + B). · If Test...
Read more >
Embedded C/C++ Unit Testing Basics - Interrupt - Memfault
The unit test will now, at the start of every test, create a directory called blocks/ , format and mount the filesystem there,...
Read more >
Adding Unit Tests to a C Project - NetBeans IDE Tutorial
The IDE provides a few ways to run tests. You can right-click the project node, or the Test Files folder, or a test...
Read more >
Unit testing C programs - CodeAhoy
The solution is to write the test code first, and run it directly from your Makefile every time you save and compile your...
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