diff --git a/docs/docs/execution/engine-modes.md b/docs/docs/execution/engine-modes.md index aa45293abd..62610b435c 100644 --- a/docs/docs/execution/engine-modes.md +++ b/docs/docs/execution/engine-modes.md @@ -80,15 +80,15 @@ set TUNIT_EXECUTION_MODE=reflection export TUNIT_EXECUTION_MODE=reflection ``` -Alternatively, you can configure this in a `.runsettings` file: -```xml - - - - reflection - - - +Alternatively, you can configure this in a `testconfig.json` file: +```json +{ + "testingPlatform": { + "environmentVariables": { + "TUNIT_EXECUTION_MODE": "reflection" + } + } +} ``` ### Optimizing Build Performance in Reflection Mode diff --git a/docs/docs/extensions/extensions.md b/docs/docs/extensions/extensions.md index 4cdc388970..33a3805265 100644 --- a/docs/docs/extensions/extensions.md +++ b/docs/docs/extensions/extensions.md @@ -70,36 +70,29 @@ See the migration guides for detailed instructions: #### Advanced Configuration -You can customize coverage with a `.runsettings` file: - -**coverage.runsettings:** -```xml - - - - - - - - - - .*\.dll$ - - - .*tests\.dll$ - - - - - - - - +You can customize coverage with a `testconfig.json` file: + +**testconfig.json:** +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*\\.dll$"], + "Exclude": [".*tests\\.dll$"] + } + } + } + } +} ``` -**Use it:** +Place the `testconfig.json` file in the same directory as your test project. It will be picked up automatically when running tests. + +**Alternatively, you can use an XML coverage settings file:** ```bash -dotnet run --configuration Release --coverage --coverage-settings coverage.runsettings +dotnet run --configuration Release --coverage --coverage-settings coverage.config ``` **📚 More Resources:** diff --git a/docs/docs/migration/mstest.md b/docs/docs/migration/mstest.md index 90ce04dc07..3c85f20530 100644 --- a/docs/docs/migration/mstest.md +++ b/docs/docs/migration/mstest.md @@ -1242,36 +1242,29 @@ You can view these with: ### Advanced Coverage Configuration -You can customize coverage behavior with a `.runsettings` file (same format as MSTest): +You can customize coverage behavior with a `testconfig.json` file: -**coverage.runsettings:** -```xml - - - - - - - - - - .*\.dll$ - - - .*tests\.dll$ - - - - - - - - +**testconfig.json:** +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*\\.dll$"], + "Exclude": [".*tests\\.dll$"] + } + } + } + } +} ``` -**Use it:** +Place the `testconfig.json` file in the same directory as your test project. It will be picked up automatically when running tests. + +**Alternatively, you can use an XML coverage settings file:** ```bash -dotnet run --configuration Release --coverage --coverage-settings coverage.runsettings +dotnet run --configuration Release --coverage --coverage-settings coverage.config ``` ### Troubleshooting @@ -1281,8 +1274,8 @@ dotnet run --configuration Release --coverage --coverage-settings coverage.runse - Verify you have a recent .NET SDK installed **Missing coverage for some assemblies?** -- Use a `.runsettings` file to explicitly include/exclude modules -- See [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage) +- Use a `testconfig.json` file to explicitly include/exclude modules +- See [Microsoft's documentation](https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md) **Need help?** - See [TUnit Code Coverage Documentation](../extensions/extensions.md#code-coverage) diff --git a/docs/docs/migration/nunit.md b/docs/docs/migration/nunit.md index 7545246f75..baa169f107 100644 --- a/docs/docs/migration/nunit.md +++ b/docs/docs/migration/nunit.md @@ -958,36 +958,29 @@ You can view these with: ### Advanced Coverage Configuration -You can customize coverage behavior with a `.runsettings` file: +You can customize coverage behavior with a `testconfig.json` file: -**coverage.runsettings:** -```xml - - - - - - - - - - .*\.dll$ - - - .*tests\.dll$ - - - - - - - - -``` - -**Use it:** +**testconfig.json:** +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*\\.dll$"], + "Exclude": [".*tests\\.dll$"] + } + } + } + } +} +``` + +Place the `testconfig.json` file in the same directory as your test project. It will be picked up automatically when running tests. + +**Alternatively, you can use an XML coverage settings file:** ```bash -dotnet run --configuration Release --coverage --coverage-settings coverage.runsettings +dotnet run --configuration Release --coverage --coverage-settings coverage.config ``` ### Troubleshooting @@ -997,8 +990,8 @@ dotnet run --configuration Release --coverage --coverage-settings coverage.runse - Verify you have a recent .NET SDK installed **Missing coverage for some assemblies?** -- Use a `.runsettings` file to explicitly include/exclude modules -- See [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage) +- Use a `testconfig.json` file to explicitly include/exclude modules +- See [Microsoft's documentation](https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md) **Need help?** - See [TUnit Code Coverage Documentation](../extensions/extensions.md#code-coverage) diff --git a/docs/docs/migration/xunit.md b/docs/docs/migration/xunit.md index 866360e0c0..c427465269 100644 --- a/docs/docs/migration/xunit.md +++ b/docs/docs/migration/xunit.md @@ -1288,36 +1288,29 @@ You can view these with: ### Advanced Coverage Configuration -You can customize coverage behavior with a `.runsettings` file: +You can customize coverage behavior with a `testconfig.json` file: -**coverage.runsettings:** -```xml - - - - - - - - - - .*\.dll$ - - - .*tests\.dll$ - - - - - - - - +**testconfig.json:** +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*\\.dll$"], + "Exclude": [".*tests\\.dll$"] + } + } + } + } +} ``` -**Use it:** +Place the `testconfig.json` file in the same directory as your test project. It will be picked up automatically when running tests. + +**Alternatively, you can use an XML coverage settings file:** ```bash -dotnet run --configuration Release --coverage --coverage-settings coverage.runsettings +dotnet run --configuration Release --coverage --coverage-settings coverage.config ``` ### Troubleshooting @@ -1327,8 +1320,8 @@ dotnet run --configuration Release --coverage --coverage-settings coverage.runse - Verify you have a recent .NET SDK installed **Missing coverage for some assemblies?** -- Use a `.runsettings` file to explicitly include/exclude modules -- See [Microsoft's documentation](https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-code-coverage) +- Use a `testconfig.json` file to explicitly include/exclude modules +- See [Microsoft's documentation](https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md) **Need help?** - See [TUnit Code Coverage Documentation](../extensions/extensions.md#code-coverage) diff --git a/docs/docs/troubleshooting.md b/docs/docs/troubleshooting.md index 8813d49c2f..14839f3036 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/troubleshooting.md @@ -709,7 +709,7 @@ dotnet run -- --report-trx --report-trx-filename results.trx **New (TUnit configuration):** -TUnit uses command-line flags or programmatic configuration instead of `.runsettings`: +TUnit uses command-line flags, `testconfig.json`, or programmatic configuration instead of `.runsettings`: ```bash # Parallel execution @@ -2245,37 +2245,26 @@ dotnet run --configuration Release --coverage **Solutions:** -#### 1. Create a `.runsettings` File -```xml - - - - - - - - - - - .*\.dll$ - .*MyProject\.dll$ - - - .*tests?\.dll$ - .*TestHelpers\.dll$ - - - - - - - - -``` - -#### 2. Use the Settings File +#### 1. Create a `testconfig.json` File +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*\\.dll$", ".*MyProject\\.dll$"], + "Exclude": [".*tests?\\.dll$", ".*TestHelpers\\.dll$"] + } + } + } + } +} +``` + +#### 2. Place the File in Your Test Project Directory +The `testconfig.json` file is picked up automatically. Alternatively, you can use an XML coverage settings file: ```bash -dotnet run --configuration Release --coverage --coverage-settings coverage.runsettings +dotnet run --configuration Release --coverage --coverage-settings coverage.config ``` ### Coverage Format Not Recognized by CI/CD @@ -2347,36 +2336,55 @@ ls TestResults/ **Solutions:** #### 1. Exclude Test Projects -```xml - - - - .*tests?\.dll$ - .*\.Tests\.dll$ - - + +In your `testconfig.json`: +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Exclude": [".*tests?\\.dll$", ".*\\.Tests\\.dll$"] + } + } + } + } +} ``` #### 2. Exclude Generated Code -```xml - - - .*\.g\.cs$ - .*\.Designer\.cs$ - - + +In your `testconfig.json`: +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "Sources": { + "Exclude": [".*\\.g\\.cs$", ".*\\.Designer\\.cs$"] + } + } + } + } +} ``` #### 3. Include Only Production Code -```xml - - - .*MyCompany\.MyProduct\..*\.dll$ - - - .*tests?\.dll$ - - + +In your `testconfig.json`: +```json +{ + "codeCoverage": { + "Configuration": { + "CodeCoverage": { + "ModulePaths": { + "Include": [".*MyCompany\\.MyProduct\\..*\\.dll$"], + "Exclude": [".*tests?\\.dll$"] + } + } + } + } +} ``` ## Debugging Tips