What is Coverage Snapshot?
dotCover records and stores coverage analysis data in coverage snapshots.
A coverage snapshot is a data unit containing code coverage statistics for all assemblies that were involved in a coverage run and had source code or PDB files available during the test run. Coverage snapshots are saved in files with the *.dcvr extensions and can be opened later with Visual Studio (with dotCover installed) or with dotCover standalone application.
Each item within the snapshot has its own percentage of statement coverage calculated as a ratio of the number of covered statements to the total number of statements. The coverage is rounded to the nearest whole percent.
Once you open a coverage snapshot from a file or finish a coverage test run, the snapshot is visually displayed in the Coverage Results Browser Window or in the Coverage area of the Unit Test Sessions Window .
When you run coverage analysis of unit tests on the local or a remote machine, dotCover records per-test data (i.e., which test executes which statements) into the coverage snapshot. When analyzing coverage results, this information allows you to navigate to covering tests.
In certain cases, this information is not recorded in the snapshot:
- The snapshot was obtained during a manual test session
- The snapshot was obtained with the console runner.
- The snapshot was obtained when covering MsTests and the test run configuration was specified in a legacy .testsettings file. (In the current versions of Visual Studio it is recommended to use .runsettings file for configuring unit tests.)
Per-test data also affects the way the new snapshot is merged with the currently opened snapshot when you run a single test in the Unit Test Sessions Window. If the current snapshot has per-test data, the snapshot that you get after rerunning a single unit test will contain information on all unit tests. Otherwise, the resulting snapshot will only have the information on the latest executed test.
Another thing that you should consider is that dotCover records local paths to assemblies and source files in coverage snapshots. If you open a snapshot recorded in another computer and want to visualize code coverage in files and navigate to covering tests, dotCover will try to remap the paths. If it fails to do so and you have incorrect results for these actions, you can disable mapping by clearing the Auto map source file paths in snapshots check box in the dotCover | General options page.