I am trying to get some tests to properly run in CI using the WebApplicationFactory
These tests pass locally when we run them through the IDE but they fail with
System.InvalidOperationException: Solution root could not be located using application root
When we run them in CI.
In CI, we have a directory called integration_tests
which contains multiple dll
files for the tests and we run a vstest
command to test these dlls, but we do not have the .sln
file there.
Our WebApplicationFactory goes something like this:
factory = new WebApplicationFactory<Startup>()
.WithWebHostBuilder(b =>
{
b.ConfigureTestServices(s => {});
});
client = factory.CreateDefaultClient();
I have tried using the WebApplicationFactoryContentRoot
and placing it inside the AssemblyInfo.cs
but I am unsure that we are using it the right way and I can not find any examples on the docs that actually use it with existing Integration tests.
I have also tried setting the b.UseSolutionRelativeContentRoot()
for the WebHostBuilder, but again, works only locally.
How can we properly use the WebApplicationFactoryContentRoot
to allow the WebApplicationFactory
to not only work locally but also in CI for the published dlls?