Romanx / Cake.Coverlet

Coverlet extensions for Cake Build
MIT License
40 stars 15 forks source link

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

Open charlessolar opened 3 years ago

charlessolar commented 3 years ago

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

Romanx commented 3 years ago

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?

charlessolar commented 3 years ago

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!

TerryChan2 commented 1 year ago

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.