Help with Dot Cover for dot net 7. Its not covering localization field.


We recently upgraded our project from dot net 5 to dot net 7 .Before upgrade we tested all the unit test and code coverage it was 100% but after  the upgrade it started not covering the localization field,
Here is the example of statement is not covered we mock the localization and inject it through unit test but nothing seem to work but the same unit test in dot net 5 covering the code. We have dot cover tools for vs2019 which support dot net 5 and vs 2022 which support dot net 7

1 comment

Hi Vikky George007,

The code snippet looks like a Razor code from a .cshtml page. Please correct me if I am wrong. 

AFAIK, Razor pages cannot tested directly with unit tests. Coverage of a Razor page can be taken from a web server running the web application and there might be any kind of auto-tests (integration, functional, e2e, etc) that interact with the server or the app. So, I can only guess the environment and setup of how this code extract can be tested.

I tested this behaviour with a localization service and a simple property. In both cases, I got 100% coverage of the Razor page when requesting it from the server where the app is running. I also got coverage of the supplying components written in C# with NUnit tests, but, again, not the Razor page itself. 

If you mean the code coverage highlighting in the Razor/Blazor pages, then it is yet supported and we have the corresponding issue DCVR-12300

Please share more details about the tests and the code under tests. You can also create a support request and share it privately. Thank you!


Please sign in to leave a comment.