Cake.Coverlet icon indicating copy to clipboard operation
Cake.Coverlet copied to clipboard

Running coverlet as a tool doesn't detect Test assembly correctly

Open charlessolar opened this issue 4 years ago • 3 comments

I use this extension to launch the coverlet tool (not MSBuild version) and discovered that it appears the argument customization for coverlet needs a little tweak

The code is looking for the test dll using the provided configuration - but the way it passed it to the process doesn't work due to either coverlet or dotnet test - I dont know which.

Take for example this is how coverlet is currently run via this extension

coverlet --target dotnet --targetargs "test --no-build" .\bin\**Release**\netcoreapp3.1\Aggregates.NET.UnitTests.dll

however this doesn't work

Test run for C:\Projects\Common\Aggregates.NET\src\Aggregates.NET.UnitTests\bin\**Debug**\netcoreapp3.1\Aggregates.NET.UnitTests.dll (.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.
The test source file "C:\\Projects\Common\Aggregates.NET\src\Aggregates.NET.UnitTests\bin\**Debug**\netcoreapp3.1\Aggregates.NET.UnitTests.dll" provided was not found.

For some reason even though you provide the test assembly its still trying to detect it - and incorrectly assumes Debug configuration.

The fix is to supply --configuration Release to dotnet test via target args

like so

coverlet --target dotnet --targetargs "test --no-build --configuration Release" .\Aggregates.NET.UnitTests.csproj

charlessolar avatar May 17 '21 05:05 charlessolar

This looks like you're using coverlet directly rather than using this extension for cakebuild. Do you have an example cake file that we can look at?

Romanx avatar May 17 '21 09:05 Romanx

heres a repo for this just follow the cake steps

the root problem is coverlet tool is using dotnet test but not figuring out to set --configuration so dotnet test is choosing debug by default.

If i was manually running the tool this is easy to fix so I don't think its a bug with coverlet - I think its a bug here because through cake and this extension i have no access to change the parameters to coverlet.

Something as simple as adding a Configuration property to CoverletSettings should suffice very nicely!

charlessolar avatar May 17 '21 16:05 charlessolar

Hi, any update for the above problem for setting the configuration to release? We encountered the same problem even we are using cake.coverlet 3.0.4.

TerryChan2 avatar Mar 30 '23 09:03 TerryChan2