What's magic with ApiController Attribute

157 Views Asked by At

I'm finding it difficult to understand the connection between having [ApiController] attribute and without having it.

The problem I'm facing is the tests are running and passing when executed locally (regardless having ApiController attribute or not). However with the same command execution "dotnet test test.csproj" in the Build pipeline, the same tests are failing with error http://localhost/api/xxxx returning 404 not found, and furthermore applying ApiController attribute fixes the issue in the build pipeline.

Also in the configureservices i have "services.AddControllersAsServices()", not sure if this effecting the behaviour.

please note I'm using TestServer from TestHost library in the unit tests.

can anyone explain why the ApiContoller attribute is required when running the tests in the build pipeline ?

0

There are 0 best solutions below