https://github.com/locktar/xunitv3codecoveragesample
https://github.com/locktar/xunitv3codecoveragesample
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/locktar/xunitv3codecoveragesample
- Owner: LockTar
- Created: 2025-09-25T12:19:57.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-09-25T12:50:59.000Z (9 months ago)
- Last Synced: 2025-09-25T14:45:12.763Z (9 months ago)
- Language: C#
- Size: 153 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xUnit V3 Code Coverage Sample
A sample repository for .NET 8 or later demonstrating code coverage with xUnit v3 and the Microsoft Testing Platform.
## Overview
This is a sample repository containing test projects built with **xUnit v3**. The test projects are configured to use the new **Microsoft Testing Platform (MTP)** for enhanced testing capabilities.
The best setup for a test project is to look at `Tests2` project file. See known issues at the bottom of this file for more details why.
## Code Coverage
The repository is configured to calculate code coverage using the **Microsoft code coverage extension**. For detailed documentation on this extension, see:
- [Microsoft Testing Platform Extensions - Code Coverage](https://learn.microsoft.com/en-us/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage#microsoft-code-coverage)
### Visual Studio Integration
Code coverage results can be visualized using the **Fine Code Coverage (FCC)** Visual Studio extension.
### Configuration Notes
⚠️ **Important**: The `.runsettings` file is currently disabled due to compatibility issues with the Fine Code Coverage (FCC) extension.
The extension is now creating its own `.runsettings` file automatically when running the tests in Visual Studio with the Test Explorer.
## Documentation
This sample repository is based on the official xUnit v3 documentation:
- [xUnit v3 - Code Coverage with MTP](https://xunit.net/docs/getting-started/v3/code-coverage-with-mtp)
## Requirements
- .NET 8 or later
- Visual Studio with Fine Code Coverage extension (optional, for coverage visualization). The extension is using it's default settings. This means that the setting `RunMsCodeCoverage` is set to `true`.
## Known Issues
- The Fine Code Coverage (FCC) extension is not showing the code coverage results of all the 3 test projects. It is showing only the results of the `Project1` and `Tests` projects. This is because of the configuration in the test project files. Test project `Project1` and `Tests` have the following package references:
```xml
```
The `Tests2` project is missing the `Microsoft.NET.Test.Sdk` and `xunit.runner.visualstudio` package references because they are not needed with MTP.
After adding these package references to the `Tests2` project, the FCC extension is showing the code coverage results of all 3 test projects.