running asp.net web api application in integration tests

Solution 1:

Finally found the answer. The controllers where not being found because I was running the project from a different assembly. This solution for stackoverflow made my Test pass:

https://stackoverflow.com/a/59121354/637142

In other words I ended up adding this code

// add controllers
var mvcBuilder = builder.Services.AddControllers();

// add controllers from this assembly. This is needed in case we are calling this method from unit tests project.
mvcBuilder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyCustomController).Assembly));