I want to write some integration tests for an AspNetCore web api.
In the startup code (Program.cs) there is some code setting up swagger with documentation.
Code:
builder.Services
.AddSwaggerGen(option => option.IncludeXmlComments(filePath));
So how to get this filePath?
If you look up in the net you find something like this:
Code:
var filePath = Path.Combine(AppContext.BaseDirectory, CommentFile);
As long time NCrunch user I am used to rewrite code like this to get the assembly of a type in the project and look for the xml file in the assembly´s directory.
Sadly this does not work here as the NuGet package Microsoft.AspNetCore.Mvc.Testing has a targets file which makes NCrunch copy the assembly (but not the documentation file) to the directory.
So building the solution leads to an output like this:
Code:
bin
Debug
api.dll
api.xml
api.test.dll
NCrunch creates a structure like this:
Code:
1234
1
bin
Debug
api.dll
api.xml
2
bin
Debug
api.test.dll
Once I add the NuGet package Micrsoft.AspNetCore.Mvc.Testing to my test project the result changes to:
Code:
1234
1
bin
Debug
api.dll
api.xml
2
bin
Debug
api.dll
api.test.dll
Of course now all my tests fail, cause the file api.xml is not found.
Is there any solution to this?