0

I been trying to make WebApplicationFactory<Program> to start HTTP server to do end-to-end like testing. I have tried overriding various methods and trying to add kestrel to make it listen on HTTP TCP socket.

Most approaches online seem to be building custom WebHostBuilder and injecting Startup class, but I am using minimal APIs, so Startup class is not present for me.

By default WebApplicationFactory seems to make test server that only works with a http client class and do not listen on HTTP port. As descried by question asked here.

And yes I need HTTP server, I am using Playwright to do testing. Or at last trying to.

Karolis
  • 89
  • 10
  • If you are testing with an external test engine and you need the full HTTP pipeline, then why don't you host the service at a staging/testing location or simply run it locally for the tests. If you are not able to use the `HttpClient` reference testing methodology, then you might as well run the real site. – Chris Schaller Jan 04 '22 at 06:03
  • I can't even edit this to salvage it. Playwright is used to test published web sites/services, the advice you have been reading is about how to start a local instance of your site for unit-testing purposes which you have already stated is inappropriate. So you shouldn't really be trying to do this at all. So while the tagged question is not a dup, I can't vote to re-open in this state. – Chris Schaller Jan 04 '22 at 06:10

0 Answers0