nunit3-vs-adapter: ArgumentException when whitespace sent to logger

This is related to https://github.com/nunit/nunit3-vs-adapter/issues/220. The previous fix was to send a single space when there was no text in the message, but TestSessionMessageLogger checks for IsNullOrWhitespace and throws an ArgumentException if the message is null or only whitespace, (https://github.com/Microsoft/vstest/blob/master/src/Microsoft.TestPlatform.Common/Logging/TestSessionMessageLogger.cs#L65) which means sending the single space causes an argument exception.

These are the versions we are referencing:

<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
<PackageReference Include="NUnitLite" Version="3.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Mono.Cecil" Version="0.10.0-beta6" />

We use nunit to run unit tests for IronPython. Cloning https://github.com/IronLanguages/ironpython2 and running make.ps1 then make.ps1 test-test_macurl2path will show the issue. I worked around this in a local build of the adapter by implementing my own IsNullOrWhiteSpace (since the adapter is being built with a framework prior to IsNullOrWhiteSpace) and didn’t send the message if it is null or only whitespace.

This is the output we see from tests:

.\make.ps1 test-test_macurl2path
WARNING: No tests available for 'test_macurl2path' trying to run single test 'net45.test_macurl2path'
dotnet test C:\Users\USER\Code\_ipy\ironpython2/Src/IronPythonTest/IronPythonTest.csproj -f net45 -o C:\Users\USER\Code\_ipy\ironpython2/bin/Release/net45 -c Release --no-build -l trx;LogFileName=single-net45-Release-result.trx -s C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\runsettings.xml --filter="Name=net45.test_macurl2path"
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 160.02 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Scripting\Microsoft.Scripting.csproj.
  Restore completed in 156.32 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Scripting.Metadata\Microsoft.Scripting.Metadata.csproj.
  Restore completed in 175.2 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Src\Microsoft.Dynamic\Microsoft.Dynamic.csproj.
  Restore completed in 160.26 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\DLR\Tests\ClrAssembly\ClrAssembly.csproj.
  Restore completed in 48.03 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\IronPython\IronPython.csproj.
  Restore completed in 118 ms for C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\IronPythonTest.csproj.
Test run for C:\Users\USER\Code\_ipy\ironpython2\bin\Release\net45\IronPythonTest.dll(.NETFramework,Version=v4.5)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
test_macurl2path
.
.
Error processing test-output event for
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.OnTestEvent(String report)
----------------------------------------------------------------------
Error processing test-output event for
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.OnTestEvent(String report)
Ran 2 tests in 0.159s
Error processing test-output event for
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.OnTestEvent(String report)
Error processing test-output event for
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.OnTestEvent(String report)
OK
Error processing test-output event for
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.OnTestEvent(String report)
WARNING: Overwriting results file: C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\TestResults\single-net45-Release-result.trx
Results File: C:\Users\USER\Code\_ipy\ironpython2\Src\IronPythonTest\TestResults\single-net45-Release-result.trx

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 22.1010 Seconds

We see this on both net45 and netcoreapp2.0

/cc @slozier

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 24 (15 by maintainers)

Commits related to this issue

Most upvoted comments

@mthjones Thanks and very nice! I’ll make a repro and check if this fixes it.

@kswoll Can you include a minimal test showing the problem, as I cannot make it fail. E.g. the following works on my machine

        [Test]
        public void TestConsoleWriteLine()
        {
            Console.WriteLine();
            Console.WriteLine("a");
            Console.WriteLine((string)null);
            Console.WriteLine("b");
            Console.WriteLine(" ");
        }

@CharliePoole I agree, I think I need to raise an issue with the VSTest project because sending whitespace only should be allowed, it is useful. Thanks for fixing this up!