Skip to content

Include doesn't seem to work #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rvanmaanen opened this issue Aug 29, 2018 · 11 comments
Closed

Include doesn't seem to work #183

rvanmaanen opened this issue Aug 29, 2018 · 11 comments
Labels
bug Something isn't working

Comments

@rvanmaanen
Copy link

rvanmaanen commented Aug 29, 2018

Using the NuGet integration (haven't tried the global tool), I want to be able to include only the coverage from the project I'm unit testing.

I have multiple projects and multiple test projects:

  • StackState.Core
  • StackState.Core.UnitTests
  • StackState.CLI
  • StackState.Monitor
  • StackState.Monitor.UnitTests

When I generate coverage for the "StackState.Monitor.UnitTests" project, without specifying any include or exclude filters, the result is this:

+---------------------------+--------+--------+--------+ | Module | Line | Branch | Method | +---------------------------+--------+--------+--------+ | StackState.Core | 0,4% | 0% | 0,7% | +---------------------------+--------+--------+--------+ | StackState.Core.UnitTests | 4,4% | 0% | 6,8% | +---------------------------+--------+--------+--------+ | StackState.Monitor | 37,6% | 21,7% | 56,5% | +---------------------------+--------+--------+--------+

When I add "/p:Exclude="[StackState.Core*]*"", the result is:

+--------------------+--------+--------+--------+ | Module | Line | Branch | Method | +--------------------+--------+--------+--------+ | StackState.Monitor | 37,6% | 21,7% | 56,5% | +--------------------+--------+--------+--------+

The above is actually what I want, but I want to get this result by INcluding the one project that 1 want coverage for and not EXcluding everything else. Besides that it's cumbersome, it's also currently not possible to do from a PowerShell window: #182. Anyway, changing the parameter to "/p:Include="[StackState.Monitor*]*"" results again in:

+---------------------------+--------+--------+--------+ | Module | Line | Branch | Method | +---------------------------+--------+--------+--------+ | StackState.Core | 0,4% | 0% | 0,7% | +---------------------------+--------+--------+--------+ | StackState.Core.UnitTests | 4,4% | 0% | 6,8% | +---------------------------+--------+--------+--------+ | StackState.Monitor | 37,6% | 21,7% | 56,5% | +---------------------------+--------+--------+--------+

Either I'm doing something wrong, or the include setting doesn't seem to work.

So why is this an issue at all? I'm trying to get Coverage Gutters working together with Coverlet, but when Code Gutters finds multiple coverage files with overlapping values it seems to pick the last one and not combine the data. As combining coverage results isn't possible yet with Coverlet as well, this seems to be my only way out.

@rvanmaanen
Copy link
Author

Maybe related to #122 btw?

@tonerdo
Copy link
Collaborator

tonerdo commented Sep 1, 2018

Hi @rvanmaanen, thanks for reporting this. I'm actually in the process of revamping the include/exclude capabilities of Coverlet. Will have some new updates within the week

@tonerdo
Copy link
Collaborator

tonerdo commented Sep 1, 2018

@rvanmaanen I tested this and Include seems to work just fine. Do you think you can put together a simple repro solution that I can clone? Also, while I know it's cumbersome I've provided a solution to the Powershell issue here #182 (comment)

@rvanmaanen
Copy link
Author

rvanmaanen commented Sep 11, 2018

Hi, sorry for the delay! Here is a repo containing an example: https://github.com/rvanmaanen/CoverletIncludeIssues

@rvanmaanen
Copy link
Author

Is there a reason exclude takes precedence over include? Something like the following could be useful: exclude everything and then include what you want?

dotnet test Demo2.Test /p:CollectCoverage=true /p:Include="[Demo2]*" /p:Exclude="[*]*"

@tonerdo
Copy link
Collaborator

tonerdo commented Sep 13, 2018

@rvanmaanen no particular reason, it's just by design. I took into consideration that everything is included by default and most users would typically want to start out in that default state

@jonathann92
Copy link

Hi are there any updates on the /p:Include= functionality? It doesn't work for me either and I'm using terminal on a mac.

@ElephantsGerald
Copy link

I'm having the same problem: /p:Include is not working.

@MortenChristiansen
Copy link

Same problem here. @tonerdo Might it be that the msbuild targets do not include the Include property? My understanding of target files is not great but it seems that it does not pass along the property.

@tonerdo
Copy link
Collaborator

tonerdo commented Oct 13, 2018

@MortenChristiansen thanks for pointing that out!

@MarcoRossignoli MarcoRossignoli added the bug Something isn't working label Sep 28, 2019
@MarcoRossignoli
Copy link
Collaborator

this bug is solved I did a test with last version 2.7.0 and this is my result of repro.

C:\git\coverletissue\CoverletIncludeIssues (master -> origin)
λ dotnet test Demo2.Test /p:CollectCoverage=true /p:Include="[Demo2]*
Test run for C:\git\coverletissue\CoverletIncludeIssues\Demo2.Test\bin\Debug\netcoreapp2.1\Demo2.Test.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.

Test Run Successful.
Total tests: 1
     Passed: 1
 Total time: 1,7034 Seconds

Calculating coverage result...
  Generating report 'C:\git\coverletissue\CoverletIncludeIssues\Demo2.Test\coverage.json'

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+
| Demo2  | 100% | 100%   | 100%   |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 100% | 100%   | 100%   |
+---------+------+--------+--------+
| Average | 100% | 100%   | 100%   |
+---------+------+--------+--------+

I'm going to close...feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants