Skip to content

Support --config-file flag for testconfig.json location (MTP) #2015

Description

@EraYaN

Describe the bug
As a continuation on #1887 it would be awesome if coverlet could respect the same switch as the rest of the test configuration so we don't ave to copy it to the output directory. Currently coverlet ignores the config file if it does not live in the output directory.

To Reproduce

dotnet test --config-file testconfig.json --project .\subdir\projectName.csproj --diagnostic --diagnostic-verbosity Trace

with a project using coverlet.MTP. (and the correct global.json config to enable MTP)

{
  "platformOptions": {
    "Coverlet": {
      "Include": "[Calcasa.*]*",
      "Exclude": "[coverlet.*]*,[Microsoft.VisualStudio.TestPlatform.*]*,[testhost*]*,[coverlet.*.Tests?]*,[*]Coverlet.Core*,[*]Moq*,[*]TestBase*",
      "excludeByAttribute": "Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverage,ExcludeFromCodeCoverageAttribute",
      "excludeByFile": "**/*Migrations/*.cs",
      "format": "cobertura,opencover",
      "useSourceLink": false,
      "singleHit": false,
      "includeTestAssembly": false,
      "skipAutoProps": true,
      "deterministicReport": false,
      "excludeAssembliesWithoutSources": "MissingAll"
    }
  }
}

Expected behavior
This should output the correct value in the diagnostic and respect the config items.

Actual behavior
It uses the default config.

Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package (collector, console, msbuild, ...) and version was used? coverlet.MTP 10.0.1
* Which version of .NET is the code running on? 10.0
* What OS and version, and what distro if applicable? Windows 11
* What is the architecture (x64, x86, ARM, ARM64)? x64
* Do you know whether it is specific to that configuration? Also fails on Ubuntu 26.04 x64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    driver-MTPIssue related to Microsoft Testing Platform driver

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions