Skip to content

gRPC integration test TStartup = Program.cs throws "A public method named 'ConfigureIntegrationTests' or 'Configure' could not be found in the 'Program' type." #44906

@khteh

Description

@khteh

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I follow this: https://learn.microsoft.com/en-us/aspnet/core/grpc/test-services?view=aspnetcore-6.0
and bump into:

"A public method named 'ConfigureIntegrationTests' or 'Configure' could not be found in the 'Program' type."
at Microsoft.AspNetCore.Hosting.StartupLoader.FindMethod(Type startupType, String methodName, String environmentName, Type returnType, Boolean required)
   at Microsoft.AspNetCore.Hosting.StartupLoader.FindConfigureDelegate(Type startupType, String environmentName)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services, Object instance)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostBuilderExtensions.<StartAsync>d__1.MoveNext()
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostBuilderExtensions.Start(IHostBuilder hostBuilder)
   at Web.Api.IntegrationTests.Services.GrpcTestFixture`1.EnsureServer() in C:\\Projects\\ASP.Net\\AspNetCoreWebApi\\test\\Web.Api.IntegrationTests\\Services\\GrpcTestFixture.cs:line 115

The server is configured to listen at https://localhost:5000. This happens when I use the default TestServer.CreateHandler().


Does .Net Core 6 GRPC support HTTP/3? I configure HttpHandler with the following class:

public class Http3Handler : DelegatingHandler
{
    public Http3Handler() { }
    public Http3Handler(HttpMessageHandler innerHandler) : base(innerHandler) { }
    protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
    {
        request.Version = HttpVersion.Version30;
        request.VersionPolicy = HttpVersionPolicy.RequestVersionExact;
       return await base.SendAsync(request, cancellationToken); // throws exception here
    }
}

and assign it:

    HttpHandler = new Http3Handler(Fixture.Handler)

and bump into the same error and exception shown above.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.402

Anything else?

Windows 11, Visual Studio 2022 17.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-grpcIncludes: GRPC wire-up, templates

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions