Run the following test on Win10
[Fact]
public void Test1()
{
Assert.Equal(10, Environment.OSVersion.Version.Major);
}
Problem: You get different results depending on the runner used.
VS: The test passes
dotnet test: passes
xunit.console.exe fails with:
Assert.Equal() Failure
Expected: 10
Actual: 6
This is because Windows lies about it's real version until you opt into supporting a specific version via the app.manifest file. VS and dotnet.exe already do this, but xunit.console.exe does not.
Change needed:
The xunit.console project needs to add an app.manifest containing the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--This Id value indicates the application supports Windows Vista functionality -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--This Id value indicates the application supports Windows 7 functionality-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--This Id value indicates the application supports Windows 8 functionality-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--This Id value indicates the application supports Windows 8.1 functionality-->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--This Id value indicates the application supports Windows 10 functionality-->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
With this added to the csproj:
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
Would you accept a PR for this?
Related: https://github.com/dotnet/extensions/pull/2927#issuecomment-594243348
This is useful information for v3, but is not necessary since the console runner as a "thing that loads your DLL and runs your tests" is going away.
Oh? What's replacing it?
Unit test projects will be directly executable. So you'll be able to add whatever app manifest makes sense for your own tests.
Most helpful comment
Unit test projects will be directly executable. So you'll be able to add whatever app manifest makes sense for your own tests.