Visual Studio Code C# Unit Test Debugging works only once


I have a strange problem. I am creating some unit tests for a project. I have this code:

    public void Test11()
        var factory1 = new WebApplicationFactory<IdentityMS.API.Startup>();
        var PredefinedUsers1 = new List<UserItem> {
            new UserItem{Id=0, UserName="test1", Name="test1Name", eMail=""},
            new UserItem{Id=0, UserName="test2",  Name="test2Name", eMail=""},
            new UserItem{Id=0, UserName="test3",  Name="test3Name", eMail=""}

When I want to debug this code with the "Debug Test" command in the editor everything seems to look fine. But when the Test is done I cannot start debugging again until i restart Vscode. When I debug "simpler" code everything works just as expected (I can debug multiple times).

The Output shows some things but I am not able to see anything useful. It just says the Debugging is complete and when I start debugging again it just shows the last line:

NUnit Adapter Test execution complete
Debugging complete.

----- Debugging test method IdentityMS.UnitTest.Tests.Test11 -----

And the Debug Console shows this:

Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.
Microsoft.Hosting.Lifetime: Information: Hosting environment: Development
Microsoft.Hosting.Lifetime: Information: Content root path: c:\Users\daniel.adam\ProjectsHG\IdentityMS\IdentityMS.API
"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.15\System.Security.Cryptography.Primitives.dll" wurde geladen. Das Laden von Symbolen wurde übersprungen. Das Modul ist optimiert, und die Debugoption "Nur eigenen Code" ist aktiviert.
Microsoft.Hosting.Lifetime: Information: Application is shutting down...
Microsoft.Hosting.Lifetime: Information: Waiting for the host to be disposed. Ensure all 'IHost' instances are wrapped in 'using' blocks.
Das Programm "[2040] testhost.exe" wurde mit dem Code -1 (0xffffffff) beendet.

Also when I don´t kill the debugging process it takes a long time. Everything I tried just points to the kast line of the test that does something Visual Studio Code doesn´t like.

asked on Stack Overflow May 17, 2021 by Daniel Adam • edited May 18, 2021 by Daniel Adam

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0