Skip to content

Include Filter not Working when Part of Docker ENTRYPOINT #767

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
DaleyKD opened this issue Mar 19, 2020 · 7 comments
Closed

Include Filter not Working when Part of Docker ENTRYPOINT #767

DaleyKD opened this issue Mar 19, 2020 · 7 comments
Labels
Known Issue It's a know issue

Comments

@DaleyKD
Copy link

DaleyKD commented Mar 19, 2020

When trying to use the /p:Include filter as part of a Dockerfile's ENTRYPOINT, it seems to be ignored. However, when I run the same command directly inside the docker image, it works great.

The command ran directly in the image (working directory is /app/test):

dotnet test MyProj/Test/Kyle.Suite.Project.Test/Kyle.Suite.Project.Test.csproj --logger:trx /p:Include='[Kyle.Suite.Project.*]*' /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/

Generates:

+-----------------------------------+--------+--------+--------+
| Module                            | Line   | Branch | Method |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Management     | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Data           | 4.99%  | 7.89%  | 40%    |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Resources      | 40.95% | 100%   | 38.23% |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Tenants.Data   | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Web            | 13.74% | 16.26% | 13.23% |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Web.Views      | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+

+---------+-------+--------+--------+
|         | Line  | Branch | Method |
+---------+-------+--------+--------+
| Total   | 6.64% | 5.41%  | 14.09% |
+---------+-------+--------+--------+
| Average | 9.94% | 20.69% | 15.24% |
+---------+-------+--------+--------+

To run the docker image from Windows PowerShell:

docker run --rm -v C:/src/suite/Project/Test/TestResults:/app/test/Project/Test/Kyle.Suite.Project.Test/TestResults:rw kyleTests:testrunner

Which in turn has an ENTRYPOINT like:

ENTRYPOINT ["dotnet", "test", "Project/Test/Kyle.Suite.Project.Test/Kyle.Suite.Project.Test.csproj", "--logger:trx", "/p:Include='[Kyle.Suite.Project.*]*'", "/p:CollectCoverage=true", "/p:CoverletOutputFormat=cobertura", "/p:CoverletOutput=TestResults/"]

Generates:

+-----------------------------------+--------+--------+--------+
| Module                            | Line   | Branch | Method |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Messaging.Azure        | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Go365.Management       | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Authentication         | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Common.Razor           | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Common.AspNet          | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Resources              | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Data           | 4.99%  | 7.89%  | 40%    |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.EventLog.Data          | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Resources      | 40.95% | 100%   | 38.23% |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Tenants.Data   | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Common                 | 29.37% | 11.29% | 41.66% |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Security               | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Messaging              | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Web            | 13.74% | 16.26% | 13.23% |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Project.Web.Views      | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Tenancy                | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+
| Kyle.Suite.Messaging.RabbitMQ     | 0%     | 0%     | 0%     |
+-----------------------------------+--------+--------+--------+

+---------+-------+--------+--------+
|         | Line  | Branch | Method |
+---------+-------+--------+--------+
| Total   | 5.02% | 4.46%  | 9.24%  |
+---------+-------+--------+--------+
| Average | 5.23% | 7.96%  | 7.83%  |
+---------+-------+--------+--------+

What am I doing wrong?

@MarcoRossignoli
Copy link
Collaborator

If your app is a .NET core app you should use collectors, I also saw that you're using RabbitMQ one of the reason to use collectors because we found cases when rabbit shutdown fires known issue https://github.com/tonerdo/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test

If you use collectors with runsettings file you shouldn't have problem with quotes escapes https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md

@MarcoRossignoli MarcoRossignoli added the needs more info More details are needed label Mar 21, 2020
@DaleyKD
Copy link
Author

DaleyKD commented Mar 27, 2020

Marco,

That does appear to work better. However, there's one major issue that affects me changing over:

I can't seem to change the output directory of the reports. It uses the results-directory, but always puts it in a subfolder. That's not working with my Azure build pipeline.

@DaleyKD
Copy link
Author

DaleyKD commented Mar 27, 2020

Yeah... looking at the code, it seems that collector uses AttachmentManager without letting me set the reportDirectoryName. Putting it in the Guid.NewGuid() folder doesn't work for me.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Mar 27, 2020

Unfortunately we cannot change that at the moment is a vstest plat behaviour #500 (comment) but you can specify the root folder #500 (comment)

@MarcoRossignoli MarcoRossignoli added Known Issue It's a know issue and removed needs more info More details are needed labels Mar 27, 2020
@DaleyKD
Copy link
Author

DaleyKD commented Mar 27, 2020

Go ahead and close this, then. I'm glad you consider this a known issue, but it's not documented very well, if at all.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Mar 27, 2020

The home page report vstest integration the best and preferred way to use coverage https://github.com/tonerdo/coverlet/blob/master/README.md#quick-start, what do you think we can do to better explain that?
Please let me know how we can improve documentation!
Sorry for the inconvenience.

@MarcoRossignoli
Copy link
Collaborator

We added documentation on -r|--results-directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Known Issue It's a know issue
Projects
None yet
Development

No branches or pull requests

2 participants