Replies: 3 comments 1 reply
-
I stumbled upon this post while looking for answers on how to make integration tests run within a CI task in azure devops. In my case the issue was that I was executing tests with published tests (so no solution file). Ultimately I got it to work with just the csproj changes as below
I used the appSettings.json file as tracker as mentioned in one of the other issues: |
Beta Was this translation helpful? Give feedback.
-
@baligavinod Are you setting the key value for If I use |
Beta Was this translation helpful? Give feedback.
-
key value for WebApplicationFactoryContentRoot is just assembly name in my case. Custom web application factory implementation looks like below
Startup is the startup class living in web application project. I don't have inherited startup class in my case. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am learning how to use the WebApplicationFactory in ASP.NET Core 3.1. In particular I am trying to figure out the correct usage of WebApplicationFactoryContentRootAttribute
I am trying to use this attribute to set the content root for a Startup bootstrap class at
../../../Src/WebApp
.When I run
dotnet test
for the code below it does not appear to be referencing the WebApplicationFactoryContentRootAttribute settings.A
System.IO.DirectoryNotFoundException
is thrown : 'my solution base dir'/WebApp.The path should be 'my solution base dir'/Src/WebApp.
How do I get the derived WebApplicationFactory to recognise the WebApplicationFactoryContentRootAttribute
Integration Test
Test project
Also tried adding the Assembly attribute in the test csproj file by adding this fragment:
Can see that this adds the attribute to the generated AssemblyInfo.cs in obj/Debug/netcoreapp3.1:
So, how do I get the .NET Core WebApplicationFactory to look at 'solutiondir'/Src/WebApp instead of 'solutiondir'/WebApp'? Am I using the wrong value for the attribute key property?
According to Microsoft documentation
I am using a key value set to the FullName of the assembly containing my Startup class. Is this correct?
Beta Was this translation helpful? Give feedback.
All reactions