vscode-csharp: No output or errors from nunit tests - 1.10.0-beta2

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     debian
 OS Version:  8
 OS Platform: Linux
 RID:         debian.8-x64
 Base Path:   /usr/share/dotnet/sdk/1.0.4

VS Code version: C# Extension version: 1.12.1

omnisharp-vscode: 1.10.0-beta2

Steps to reproduce

Here is a repo which exactly reproduces this https://github.com/tomzo/bug-nunit-no-output-vscode

Just run

dotnet restore
dotnet test DefaultTests/DefaultTests.csproj

Then try the same in vscode by clicking on run test on one of the tests.

Expected behavior

There are tests which are failingand there is standard output printed in one of the tests.

[Test]
        public void Test1()
        {
			new Class1 ();
            Console.WriteLine("Test body running..");
        }

		[Test]
        public void Test2()
        {
            Assert.AreEqual(2,26);
        }

I would expect to see both the stdout and especially failed asserts from nunit test cases.

Actual behavior

In VsCode .NET Test Log output just counts the failed tests

NUnit Adapter 3.8.0.0: Test discovery starting
NUnit Adapter 3.8.0.0: Test discovery complete
NUnit Adapter 3.8.0.0: Test execution started
Running selected tests in /ide/work/nunit-repro/DefaultTests/bin/Debug/netcoreapp1.0/DefaultTests.dll
NUnit3TestExecutor converted 2 of 2 NUnit test cases
NUnit Adapter 3.8.0.0: Test execution complete

Total tests: 1. Passed: 0. Failed: 1. Skipped: 0

The output when running with dotnet is fine:

$ dotnet test  DefaultTests/DefaultTests.csproj 
Build started, please wait...
/usr/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.targets(40,3): warning MSB4011: "/usr/share/dotnet/sdk/1.0.4/Microsoft.CSharp.targets" cannot be imported again. It was already imported at "/ide/work/nunit-repro/ExampleLib/ExampleLib.csproj (28,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
Build completed.

Test run for /ide/work/nunit-repro/DefaultTests/bin/Debug/netcoreapp1.0/DefaultTests.dll(.NETCoreApp,Version=v1.0)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in /ide/work/nunit-repro/DefaultTests/bin/Debug/netcoreapp1.0/DefaultTests.dll
NUnit3TestExecutor converted 2 of 2 NUnit test cases
NUnit Adapter 3.8.0.0: Test execution complete
Failed   Test2
Error Message:
   Expected: 2
  But was:  26

Stack Trace:
at DefaultTests.UnitTest1.Test2() in /ide/work/nunit-repro/DefaultTests/UnitTest1.cs:line 20


Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.
Test Run Failed.
Test execution time: 1.8351 Seconds

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17

Most upvoted comments

Thanks @bernardbr Nice to see some progress on the way

This issue was moved to nunit/nunit3-vs-adapter#329

Looks like this is an NUnit issue. The NUnit adapter has only ever been used in Visual Studio before. In Visual Studio the errors are displayed in a test results window, not in the output. I created an xUnit project and they output the results to the output so we should do the same.

I miss an option to run and debug all test fixtures, but I’m afraid this doesn’t exist on VsCode.

That’s not a big problem.

You can try run the Test1 and see this output:

Yes, I can see that output from the very begging. To be clear - my point is that for Test2 it should contain Error message and stack trace:

NUnit3TestExecutor converted 2 of 2 NUnit test cases
NUnit Adapter 3.8.0.0: Test execution complete
Failed   Test2
Error Message:
   Expected: 2
  But was:  26

Stack Trace:
at DefaultTests.UnitTest1.Test2() in /ide/work/nunit/bug-nunit-no-output-vscode/DefaultTests/UnitTest1.cs:line 20

But now it is just

NUnit Adapter 3.8.0.0: Test discovery starting
NUnit Adapter 3.8.0.0: Test discovery complete
NUnit Adapter 3.8.0.0: Test execution started
Running selected tests in /ide/work/nunit/DefaultTests/bin/Debug/netcoreapp1.1/DefaultTests.dll
NUnit3TestExecutor converted 2 of 2 NUnit test cases
NUnit Adapter 3.8.0.0: Test execution complete

Total tests: 1. Passed: 0. Failed: 1. Skipped: 0