Skip to content

Microsoft.NET.Test.Sdk is required when running in MTP mode #229

@yodasad

Description

@yodasad

When using Microsoft Testing Platform, the reference to the Microsoft.NET.Test.Sdk package is no longer required.
For example, that's the quote from Xunit docs:

If you want to rely solely on Microsoft Testing Platform support, you can remove the package references to xunit.runner.visualstudio and Microsoft.NET.Test.Sdk.

But JunitXml.TestLogger implicitly requires the Microsoft.NET.Test.Sdk, because if we run tests on a project that does not have such a reference the following error occurs:

Error output: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
  
  File name: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
     at Spekt.TestLogger.Core.TestResultStore..ctor() in /home/runner/work/testlogger/testlogger/src/TestLogger/Core/TestResultStore.cs:line 10
     at Spekt.TestReporter.TestReporter.CreateTestRun(IServiceProvider serviceProvider) in /home/runner/work/testlogger/testlogger/src/TestLogger/TestReporter.cs:line 160
     at Spekt.TestReporter.TestReporter.IsEnabledAsync() in /home/runner/work/testlogger/testlogger/src/TestLogger/TestReporter.cs:line 81
     at Microsoft.Testing.Platform.TestHost.TestHostManager.BuildDataConsumersAsync(ServiceProvider serviceProvider, List`1 alreadyBuiltServices) in /_/src/Platform/Microsoft.Testing.Platform/TestHost/TestHostManager.cs:line 177
     at Microsoft.Testing.Platform.Hosts.TestHostBuilder.BuildTestFrameworkAsync(TestFrameworkBuilderData testFrameworkBuilderData) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.cs:line 682
     at Microsoft.Testing.Platform.Hosts.ConsoleTestHost.InternalRunAsync(CancellationToken cancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/ConsoleTestHost.cs:line 56
     at Microsoft.Testing.Platform.Hosts.CommonHost.RunTestAppAsync(CancellationToken testApplicationCancellationToken) in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 115
     at Microsoft.Testing.Platform.Hosts.CommonHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 54
     at Microsoft.Testing.Platform.Hosts.CommonHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 62
     at Microsoft.Testing.Platform.Hosts.CommonHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/CommonTestHost.cs:line 74
     at Microsoft.Testing.Platform.Builder.TestApplication.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs:line 227
     at Xunit.MicrosoftTestingPlatform.TestPlatformTestFramework.RunAsync(String[] args, Action`2 extensionRegistration) in /_/src/common/MicrosoftTestingPlatform/TestPlatformTestFramework.cs:line 334
     at Records.UnitTests.AutoGenerated.XunitAutoGeneratedEntryPoint.Main(String[] args) in /builds/cloud/dss/tests/UnitTests/AuditService/Records.UnitTests/obj/Debug/net10.0/XunitAutoGeneratedEntryPoint.cs:line 13

Is it possible to remove such a reference for MTPv2 mode?

  • Test Runner: MTPv2
  • Test Framework: Xunit
  • .NET project version, sdk version: net10.0
  • Command line used (please share the test run command):
dotnet test --solution audit.slnx --report-spekt-junit "MethodFormat=Class;FailureBodyFormat=Verbose;" --report-spekt-junit-filename "$ROOT/artifacts/tests/{assembly}-test-result.xml" --filter-query "/!*IntegrationTests"
  • OS: Linux/Windows

Expected behavior
No errors occur during test run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions