How to use dotCover cover-iis to get coverage for web API that host on IIS with OutProcess module

I want to get coverage for web API that host on IIS. I can get coverage result by using cover-iis that within w3wp.exe process, but I can't get the coverage for the OutProcess web API because it has seperate process. Is there solution or workaround to get the coverage.

Any suggestion will be appreciated.

0
4 comments
Hello,

Try using "cover-everything" command (https://www.jetbrains.com/help/dotcover/dotCover__Console_Runner_Commands.html#cover-everything). Note the command prompt should be opened with administrator rights. 
As a complete alternative, I may suggest considering Kestrel as a web server for testing and coverage purposes. Here is an article on how to cover Web API when it is launched with dotnet https://dotnettools-support.jetbrains.com/hc/en-us/articles/16257508479634-How-to-cover-ASP-NET-Core-Web-API-application-with-dotCover-CLT
0

Hello,

 Thanks for your feedback. I want to get coverage for dotnet Web API that host on IIS server. I used CLI to get coverage: 

dotcover cover-iis /Output=c:\myresult.dcvr /Instance=1

dotcover send /Command=GetSnapshotAndKillChildren /Instance=1

I CAN'T get the coverage result sometimes (The web API host IIS mixed with Out-Process and In-Process model, and I have tests hit the code). Could you give me some possible reasons why this could happen.

Thanks a lot.

0

Hello ,

I got the possible root cause is, there are system environment configuration on my server setting profiler. Do you have any idea to overwrite the configurations while executing dotCover instead of changing the configuration directly? Thanks a lot.

COR_ENABLE_PROFILING
COR_PROFILER
COR_PROFILER_PATH_64
COR_PROFILER_PATH_32

CORECLR_ENABLE_PROFILING
CORECLR_PROFILER
CORECLR_PROFILER_PATH_64
CORECLR_PROFILER_PATH_32

 

0

Hello,

Taking coverage simultaneously of In-Process and Out-Process would not be an easy task. The thing is that IIS is a Windows service under the hood, and it requires a different approach than any other standalone .NET application. 

So, I see the best approach here is to run two dotCover instances: one is for IIS, which will cover the InProcess part and the second instance with the `cover-everything` command, which will catch the OutProcess part, which is basically "dotnet.exe" process.

The environment variables can indeed prevent profiling and coverage on a machine. However, they cannot give a flaky effect. The coverage will either work or won't work at all. 

Do you have any idea to overwrite the configurations while executing dotCover instead of changing the configuration directly?

dotCover does not have a built-in mechanism for temporarily changing environment variables on Windows. Since they are global variables that are stored in the registry, I suppose even the system reboot may be required to apply them. So, I doubt such kind of system variables can be applied temporarily. 

0

Please sign in to leave a comment.