Code coverage can be automatically collected and displayed after running tests in the Test Explorer window in Visual Studio.
This functionality is available in Visual Studio 2019 or later.
- Enable the Enable Code Coverage option in the Visual Studio toolbar.
- Run the tests in the Test Explorer view.
The coverage will be automatically displayed in the Coverage view. - See Viewing Coverage for details about viewing coverage data.