❔ Issue with unit testing and projects not starting
I'm writing up tests for my controller, but I need to grab an access token for authorization to do anything. We're using OIDC and it's endpoint is
https://localhost:5001
When I run this function in test explorer, I get a System.Net.Http.HttpRequestException : No connection could be made because the target machine actively refused it. (localhost:5001)
However, when I open a separate instance of VS and run the application, then run test on the 1st VS, everything works fine. How do I make it so that I don't need to do all the shenanigans and just run the test from the test explorer?5 Replies
The code itself is fine, just having issues with my test not running all the startup project
I don't see your test code starting a web service. You'll want to read up on WebApplicationFactory
WebApplicationFactory Class (Microsoft.AspNetCore.Mvc.Testing)
Factory for bootstrapping an application in memory for functional end to end tests.
I'll look into it, thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.