coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.98k stars 386 forks source link

Empty coverage report when using the `--configuration` flag #1545

Closed tumbledwyer closed 10 months ago

tumbledwyer commented 11 months ago

Describe the bug When using anything but the default configuration, code coverage report is empty. Default configuration works perfectly with the following command: dotnet test --no-restore --verbosity minimal ./MySolution.sln --collect:"XPlat Code Coverage" --results-directory ./coverage

To Reproduce Run dotnet test --no-restore --configuration Test --verbosity minimal ./MySolution.sln --collect:"XPlat Code Coverage" --results-directory ./coverage

Expected behavior Complete coverage report

Actual behavior Empty report

<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0" branch-rate="0" version="1.9" timestamp="1698739959" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0">
  <sources />
  <packages />
</coverage>

Configuration: Here is the csproj of the test project

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\..\common.props"></Import>
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
    <AssemblyName>MySolution.Tests</AssemblyName>
    <PackageId>MySolution.Tests</PackageId>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    <Configurations>Test;Stage;Debug;Release</Configurations>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' ">
    <IntermediateOutputPath>obj\Test</IntermediateOutputPath>
    <DebugType></DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Test</OutputPath>
    <DefineConstants></DefineConstants>
    <WarningLevel>4</WarningLevel>
    <NoWarn></NoWarn>
    <NoStdLib>false</NoStdLib>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="coverlet.collector" Version="6.0.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
    <PackageReference Include="MockQueryable.NSubstitute" Version="7.0.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>

Is there something I'm missing?

Bertk commented 11 months ago

Hi,

please provide binary build log and diagnosis test log.

1)

2) please also check the latest preview from coverlet-nightly build

Bertk commented 10 months ago

I will close the issue because there is no additional information provided.

Code coverage will be available with default configurations [Debug|Release]. Customized build configurations has to be supported by the user.