-
Notifications
You must be signed in to change notification settings - Fork 2.1k
HTTP 404 with ASP.NET Core Test Server when controllers are added to a seperate assembly #5992
Comments
I reproduced this. Looks like it is not specific to ASP.NET Core web app referencing .NET Standard. I was able to reproduce this when creating a separate .NET Core shared library as well for the controllers. Web application responds when it is hosted in IIS, but when we bypass IIS hosting and instead use TestServer, it appears to not be able to find controller actions |
For the records: the app running in Kestrel is fine. It just broke my integration tests when moving some controllers to a separate assembly. |
I am seeing this same problem. The workaround of using the AddApplicationPart extension works fine, but it has me worried about what else may be different between the TestServer and Kestrel. |
To fix this you'd have to do something like what we do here https://github.com/aspnet/Mvc/blob/dev/test/Microsoft.AspNetCore.Mvc.FunctionalTests/MvcTestFixture.cs#L61 We're currently working on productizing our functional testing infrastructure so it's a reusable package #6433 |
To everyone posting here, we're releasing a preview build as part of 2.0.0 of a new testing package to add the features needed to test MVC with TestServer. This is basically a friendlier version of what the team has been using to test MVC for the past few years. See: https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNetCore.Mvc.Testing I'm closing this issue because we think that this resolves all of the issues that have been reported about difficulties of testing with TestServer. If you have a unique issue, or your problem isn't resolve by this, or you need more help, please open a new issue. Thanks! |
What name does this have now, @rynowak ? The |
@johnkors the package will be released as part of the 2.1.0 release. The unlisted version is there to reserve the package id on nuget.org. |
Microsoft.AspNetCore.Mvc.Testing should this package be available on nuget or is it part of a other package? i'm only able to find this one: |
Check my comment directly above yours, @mathysd :) It's in the myget feeds. |
To use controllers in a separate assembly, i have to use a package from myget or add application part in startup, did I understand correctly? Is there no other way? |
This issue should still be open? @johnkors tried to install it but was failing on dependencies |
Installing works OK, so if you're not able to install - that sounds seperate to the issue at hand here @wpitallo .
|
How can I use this
But and now? |
And now to make matters worse, after some days, it begin works on my computer but in another my notebook, not! Really stranger....... |
After migrating on 2.1 (aspnet nuget + target necore2.1), I found the same issue. |
@rducom could you file a new issue? |
Same issue here after updating to 2.1. I was able to fix that by changing test projects' SDK to |
@dzimchuk the fix you made looks correct. @danroth27 did we add this requirement to the 2.1 announcement post? |
@rynowak I am still seeing this issue with latest dotnet core 2.1. Here is the screenshot of the nuget package to show the version of TestServer library I am using I tried the workaround mentioned above which was to register the Assembly of the controller in my api project |
Hi, it looks like you are posting on a closed issue/PR/commit! We're very likely to lose track of your bug/feedback/question unless you:
Thanks! |
I have a basic test controller within my ASP.NET Core application:
This is stored within my VS solution as follows:
With this configuration I receive a HTTP 200 when attempting to access TestController via localhost, and my integration test passes using the following scenario:
If I move the same controller to a separate .NET Standard based library in the following structure:
In addition to ensuring my 'Web' project references the given library:
Then the same integration test referenced above fails, however the localhost test returns a HTTP 200 as expected.
I would expect the seperation of the TestController into a seperate binary to work against the TestServer too - have I missed a manual step?
For reference there's a reproducable example here - https://github.com/JamieKeeling/HelloWorldCore/tree/ControllerBinary
The text was updated successfully, but these errors were encountered: