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"
Expected behavior
No errors occur during test run.
When using Microsoft Testing Platform, the reference to the
Microsoft.NET.Test.Sdkpackage is no longer required.For example, that's the quote from Xunit docs:
But
JunitXml.TestLoggerimplicitly requires theMicrosoft.NET.Test.Sdk, because if we run tests on a project that does not have such a reference the following error occurs:Is it possible to remove such a reference for MTPv2 mode?
Expected behavior
No errors occur during test run.