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.

Tests not executed if Console.WriteLine() is used

See original GitHub issue

If the code path executed during a test contains a Console.WriteLine() without text content, the test will not execute. The following error is reported in the test output:

System.ArgumentException: The parameter cannot be null or empty.
Parameter name: message
   at Microsoft.VisualStudio.TestPlatform.Common.Logging.TestSessionMessageLogger.SendMessage(TestMessageLevel testMessageLevel, String message)
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.TestFinished(INUnitTestEventTestCase resultNode) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEventListener.cs:line 164
   at NUnit.VisualStudio.TestAdapter.NUnitEventListener.OnTestEvent(String report) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEventListener.cs:line 92

Here is code that reproduces this problem:

[TestFixture]
public class Tests {
    [Test]
    public void DoesNotWorkIn4alpha1() {
        Console.WriteLine();
        Assert.Pass();
    }

    [Test]
    public void Works() {
        Console.WriteLine("content");
        Assert.Pass();
    }
}

NUnit3TestAdapter 4.0.0-alpha.1 NUnit 3.12.0 Visual Studio Professional 2019 - 16.6.2 .Net Framework 4.8

This worked in NUnit3TestAdapter 3.15.1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
OsirisTerjecommented, Dec 22, 2021

@MisinformedDNA Just to clarify the current state. 3.18 will not be released, 3.17 will be the latest in the 3.X series. The 4.X series do support legacy csproj with old packages.config, and will continue to do so as long as we are able to maintain it. The 4.X series will not have any VSIX.

0reactions
OsirisTerjecommented, Apr 22, 2021

It is still planned, but the way forward is the 4.0.0. We expect 4.0.0 to not support legacy csproj with old package.configs, and it will not have a vsix either. 3.18 will try to cover as much as it can of the 4.0.0 features, but will still support the old legacy and will have a vsix. The release will follow the 4.0.0 release though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I write into the console in a unit test? If yes, why doesn' ...
We can use Console.WriteLine normally and the output is displayed, just not in the Output window, but in a new window after we...
Read more >
VS 2019 Console.Writeline - Output not present in ...
So, I am used to using Console.Writeline during development to generate debugging output (and then remove them and comment them out when no ......
Read more >
How to Console.WriteLine from [TestMethod]?
WriteLine runs fine and we can see it in 'output' window, but on this project we must to use Testing tools embebed with...
Read more >
How to Write to Console in Unit Test in Visual Studio 2022
The easiest way to write output from the test is to use the Console.WriteLine method. [TestMethod] public void test_that_writes_to_console2() { Console.
Read more >
Visual Studio 2019 test output window lost. Not the VS ...
But when I just use Console.WriteLine("Hello"), the output is discarded and not displayed anywhere. Still this is confusing...
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