visualstudio.xunit
visualstudio.xunit copied to clipboard
Doesn't work with dotnet test on SDK-style .NET Framework projects with case sensitivity enabled
Example .csproj (the default template, but net472).
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Empty test stub
using Xunit;
namespace PrimeService.Tests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}
dotnet test fails to find runner utility due to all caps extension '.DLL'
PS C:\Users\lilith\imazen\resizer\PrimeService.Tests> dotnet test
Determining projects to restore...
Restored C:\Users\lilith\imazen\resizer\PrimeService.Tests\PrimeService.Tests.csproj (in 162 ms).
PrimeService.Tests -> C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\PrimeService.Tests.dll
Test run for C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\PrimeService.Tests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.26] PrimeService.Tests: Catastrophic failure: System.ArgumentException: File not found: C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\xunit.runner.utility.net452.DLL
Parameter name: assemblyFileName
at Guard.FileExists(String argName, String fileName) in /_/src/common/Guard.cs:line 37
at Xunit.AppDomainManager_AppDomain..ctor(String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder) in /_/src/xunit.runner.utility/AppDomain/AppDomainManager_AppDomain.cs:line 18
at Xunit.DiaSessionWrapper..ctor(String assemblyFilename) in /_/src/xunit.runner.utility/Utility/DiaSessionWrapper.cs:line 21
at Xunit.VisualStudioSourceInformationProvider..ctor(String assemblyFileName) in /_/src/xunit.runner.utility/Frameworks/VisualStudioSourceInformationProvider.cs:line 24
at Xunit.XunitFrontController..ctor(AppDomainSupport appDomainSupport, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink) in /_/src/xunit.runner.utility/Frameworks/XunitFrontController.cs:line 70
at Xunit.Runner.VisualStudio.VsTestRunner.RunTestsInAssembly(IRunContext runContext, IFrameworkHandle frameworkHandle, LoggerHelper logger, TestPlatformContext testPlatformContext, RunSettings runSettings, IMessageSinkWithTypes reporterMessageHandler, AssemblyRunInfo runInfo) in /_/src/xunit.runner.visualstudio/VsTestRunner.cs:line 498
No test is available in C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\PrimeService.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
As does powershell
PS C:\Users\lilith\imazen\resizer\PrimeService.Tests> ls C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\xunit.runner.utility.net452.DLL
ls : Cannot find path 'C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\xunit.runner.utility.net452.DLL' because it does not exist.
At line:1 char:1
+ ls C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\lilith...lity.net452.DLL:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
PS C:\Users\lilith\imazen\resizer\PrimeService.Tests> ls C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\xunit.runner.utility.net452.dll
Directory: C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472
Mode LastWriteTime Length Name
-a---- 1/18/2022 10:06 AM 255584 xunit.runner.utility.net452.dll
Disabling case sensitivity resolves the issue
(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ disable}
PS C:\Users\lilith\imazen\resizer\PrimeService.Tests> dotnet test
Determining projects to restore...
All projects are up-to-date for restore.
PrimeService.Tests -> C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\PrimeService.Tests.dll
Test run for C:\Users\lilith\imazen\resizer\PrimeService.Tests\bin\Debug\net472\PrimeService.Tests.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: - PrimeService.Tests.dll (net472)