Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xUnit under VSTest.Console does not always use the correct .NET Framework runtime - report false test failures #2376

Closed
TalAloni opened this issue Mar 27, 2020 · 1 comment · Fixed by #2493

Comments

@TalAloni
Copy link

I have created a minimal xUnit test project demonstrating the problem (the test project use the SDK-style csproj, and target net472).
when running the test with 'dotnet test' and on some machines also VSTest.Console, it will throw the following exception:
System.ArgumentException : The specified value is not valid in the 'SslProtocolType' enumeration.
This exception is not thrown by .NET Framework 4.7.2

This issue does not occur with MSTest v2.

Project demonstrating the problem:
https://github.com/TalAloni/dotnettest-xunit

@nohwnd
Copy link
Member

nohwnd commented Mar 27, 2020

Thanks for reporting, I see the same. I took your code and put it into net472 console app and it succeeded, and then put it in net451 app and it crashed with the error that you've shown. This is most likely due to testhost.exe being compiled against net451.

Reposting similar my repro, using your code in case you'd delete the repo before we fix this.

<!-- file net.csproj -->
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <!-- change to net451 to see it fail, this shows that testhost.exe is also running using net451 rather than net472 -->
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

</Project>
// file Program.cs
using System;
using System.IO;
using System.Net.Security;
using System.Security.Authentication;

namespace net
{
    class Program
    {
        static void Main(string[] args)
        {
            MemoryStream stream = new MemoryStream();
            SslStream sslStream = new SslStream(stream);
            sslStream.BeginAuthenticateAsClient("google.com", null, SslProtocols.None, false, new AsyncCallback(ProcessInformation), nul
l);
        }

         static void ProcessInformation(IAsyncResult result)
        {
        }
    }


}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants