Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Running tests against net9.0-windows10.0.26100 silently fails #4942

@czdietrich

Description

@czdietrich

NUnit silently fails to execute tests when compiled against a Windows SDK version that is not installed locally.
This seems to be a regression, because the issue is not reproducible with NUnit 4.1.0.

Installed .NET SDK: 9.0.102

Steps to reproduce

Create a simple test project:

TestProject.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <!-- Supposed you do not have the Windows SDK for 10.0.26100 installed, else use a different version -->
    <TargetFramework>net9.0-windows10.0.26100</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
    <PackageReference Include="NUnit" Version="4.3.2" />
    <PackageReference Include="NUnit.Analyzers" Version="4.6.0"/>
    <PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
  </ItemGroup>

</Project>

Tests.cs

namespace TestProject;

using NUnit.Framework;

public class Tests
{
    [Test]
    public void Test_Something()
    {
        Assert.That( true );
    }
}

Compile and run the test project. (run dotnet test)

Expected result

The test runs successfully with something like:

Test summary: total: 1; failed: 0; succeeded: 1; skipped: 0; duration: 0.9s
Build succeeded in 1.7s

Actual result

Test execution skips all tests without an error:

NUnit Adapter 5.0.0.0: Test execution started
Running all tests in C:\Projects\TestProject\TestProject\bin\Debug\net9.0-windows10.0.26100\TestProject.dll
   NUnit failed to load C:\Projects\TestProject\TestProject\bin\Debug\net9.0-windows10.0.26100\TestProject.dll
NUnit Adapter 5.0.0.0: Test execution complete
Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.
  TestProject test succeeded with 1 warning(s) (2.7s)
    C:\Program Files\dotnet\sdk\9.0.102\Microsoft.TestPlatform.targets(48,5): warning : No test is available in C:\Projects\TestProject\TestProject\bin\Debug\net9.0-windows10.0.26100\TestProject.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Test summary: total: 0; failed: 0; succeeded: 0; skipped: 0; duration: 2.7s
Build succeeded with 1 warning(s) in 3.6s

Other information

If I do the same with net9.0-windows10.0.22621 (which is installed on my machine), net9.0-windows or net9.0 it works just fine.
If I use NUnit 4.1.0 it also works fine.
If I replace NUnit with MSTest it also works fine, so it seems to be special to NUnit.
If I use the new Microsoft.Testing.Platform the execution still fails, but there is at least some error message:

  TestProject test failed with 1 error(s) (0.9s)
    C:\Projects\TestProject\TestProject\bin\Debug\net9.0-windows10.0.26100\TestProject.dll : error run failed: Tests failed: 'C:\Projects\TestProject\TestProject\bin\Debug\net9.0-windows10.0.26100\TestResults\TestProject_net9.0-windows10.0.26100_x64.log' [net9.0-windows10.0.26100|x64]

Test summary: total: 0; failed: 0; succeeded: 0; skipped: 0; duration: 0.4s
Build failed with 1 error(s) in 1.9s

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateWe will look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions