For some reason, when ASP.NET core controllers are created in separate assembly, the TestServer is not able to find controller actions when the client makes a request.(results in 404 response) Why is this? How can I work around it? Here are steps to reproduce.
- Create new ASP.NET Core WebAPI using .NET core
- Create integration tests in separate project and configure the test to use TestServer() client and get tests to work successfully.
- Now, separate the controller into its own shared library and refactor project created in step 1 to use this shared library instead.
- Re-run test which contains the TestServer() class. You'll notice now it fails.
See the follwing link for creating the integration tests. Integration testing w/ ASP.NET Core