Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.6] GenerateTestingPlatformEntryPoint=false removes TestingPlatformBuilderHook.AddExtensions #3883

Closed
AliveDevil opened this issue Sep 30, 2024 · 4 comments
Assignees

Comments

@AliveDevil
Copy link

Describe the bug

When supplying your own entrypoint, with disabled GenerateTestingPlatformEntryPoint, CodeCoverage and MSTest aren't injected into the SelfRegisteredExtensions.

Steps To Reproduce

<Project Sdk="MSTest.Sdk">
  <PropertyGroup>
    <GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>
  </PropertyGroup>
</Project>

Program.cs:

public static async Task<int> Main(string[] args)
{
    var builder = await TestApplication.CreateBuilderAsync(args);
    SelfRegisteredExtensions.AddSelfRegisteredExtensions(builder, args);

    using var app = await builder.BuildAsync();
    return await app.RunAsync().ConfigureAwait(false);
}

Fails with:

Unhandled exception. System.InvalidOperationException: Testframework-Adapter not registered. Use "ITestApplicationBuilder.RegisterTestFramework", to register.
   at Microsoft.Testing.Platform.Builder.TestApplicationBuilder.BuildAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplicationBuilder.cs:line 102`

Expected behavior

AddSelfRegisteredExtensions shouldn't omit TestPlatform registration.

Actual behavior

AddSelfRegisteredExtensions contains additional calls, when enabling GenerateTestingPlatformEntryPoint:

public static void AddSelfRegisteredExtensions(this ITestApplicationBuilder builder, string[] args)
{
	Microsoft.Testing.Platform.MSBuild.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.Telemetry.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.VisualStudio.TestTools.UnitTesting.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.Retry.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.HangDump.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.CrashDump.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.CodeCoverage.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.TrxReport.TestingPlatformBuilderHook.AddExtensions(builder, args);
}

Versus, when disabling entrypoint generation:

public static void AddSelfRegisteredExtensions(this ITestApplicationBuilder builder, string[] args)
{
	Microsoft.Testing.Platform.MSBuild.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.Telemetry.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.Retry.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.HangDump.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.CrashDump.TestingPlatformBuilderHook.AddExtensions(builder, args);
	Microsoft.Testing.Extensions.TrxReport.TestingPlatformBuilderHook.AddExtensions(builder, args);
}

When carbon copying the generated entrypoint code (which this is) there must not be different observed behavior.

Additional context

@Evangelink
Copy link
Member

Looking

@Evangelink
Copy link
Member

Thanks @AliveDevil! Sorry for the inconvenience, we are working on a fix and will be releasing the bug fix version soon!

@Evangelink
Copy link
Member

17.12.5 of Code Coverage was just released, this will be incorporated in MSTest.Sdk 3.6.1.

@Evangelink
Copy link
Member

Everything is now ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants