coverlet-coverage / coverlet

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

.NET core SDK only outputting cobertura format #984

Closed CraigChamberlain closed 3 years ago

CraigChamberlain commented 3 years ago

I have found several examples as follows which work fine:

dotnet test --collect:"XPlat Code Coverage"

However, I've also read that the following should work

dotnet test  /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

As I'm trying to output opencover format to upload to Coveralls.io it would be great if I could export in another format.

CraigChamberlain commented 3 years ago

Found an example here.:

dotnet test --collect:"XPlat Code Coverage" --DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=json,cobertura,lcov,teamcity,opencover

However this seems to suggest it does not support the sdk version, only the MSBuild Version? The same error occurred after adding the coverlet.msbuild package.

dotnet test --collect:"XPlat Code Coverage" --DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
MSBUILD : error MSB1001: Unknown switch.
Switch: --DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover

Similar Issue here https://github.com/coverlet-coverage/coverlet/issues/755.

petli commented 3 years ago

Look carefully at the example, it has a space between -- and the format parameter:

dotnet test --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=json,cobertura,lcov,teamcity,opencover

-- on its own is used to separate parameters to the dotnet test command and parameters to the test framework.

CraigChamberlain commented 3 years ago

Hell of a spot. Thanks so much. Working a charm now.

C

On Mon, 2 Nov 2020 at 13:40, Peter Liljenberg notifications@github.com wrote:

Look carefully at the example, it has a space between -- and the format parameter:

dotnet test --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=json,cobertura,lcov,teamcity,opencover

-- on its own is used to separate parameters to the dotnet test command and parameters to the test framework.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/coverlet-coverage/coverlet/issues/984#issuecomment-720478526, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALRDEQYY6E7LR6J2JGFVYZDSN2ZGLANCNFSM4THOT4NA .

-- *Craig Chamberlain | *IT Services {tel: 07526825153} {web: www.craigchamberlain.it}

petli commented 3 years ago

Good to hear!