grpc-dotnet icon indicating copy to clipboard operation
grpc-dotnet copied to clipboard

Integration test with minimal APIs

Open listepo opened this issue 2 years ago • 7 comments

@JamesNK how to write integration tests with minimal APIs?

listepo avatar Apr 26 '22 21:04 listepo

@listepo Please use the following guide: https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-6.0

rafikiassumani-msft avatar Apr 26 '22 22:04 rafikiassumani-msft

https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60-samples?view=aspnetcore-6.0#test-with-webapplicationfactory-or-testserver is a migration guide if you're starting from an existing project.

halter73 avatar Apr 26 '22 22:04 halter73

If I'm not mistaken this is an example/docs for Microsoft.AspNetCore.Mvc.Testing, but not grpc-dotnet

listepo avatar Apr 26 '22 22:04 listepo

https://docs.microsoft.com/en-us/aspnet/core/grpc/test-services?view=aspnetcore-6.0

JamesNK avatar Apr 27 '22 03:04 JamesNK

@JamesNK thanks, but this example uses GrpcTestFixture<TStartup>, minimal APIs does not use TStartup)

listepo avatar Apr 27 '22 12:04 listepo

Triage: We need to update the docs and provide a test example with WebApplicationFactory. @listepo Can you look at the following doc? It has some guidance on how to test with a minimal host: https://docs.microsoft.com/aspnet/core/test/integration-tests?view=aspnetcore-6.0#basic-tests-with-the-default-webapplicationfactory

rafikiassumani-msft avatar Apr 28 '22 18:04 rafikiassumani-msft

I already figured it out, thanks everyone

listepo avatar Apr 28 '22 19:04 listepo