Skip to content

Custom output filename for collector #1276

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
gix opened this issue Jan 6, 2022 · 7 comments
Closed

Custom output filename for collector #1276

gix opened this issue Jan 6, 2022 · 7 comments
Labels
driver-collectors Issue related to collectors driver feature-request New feature request stale

Comments

@gix
Copy link

gix commented Jan 6, 2022

Running dotnet test --collect "XPlat Code Coverage" on a solution with multiple test projects and/or test projects with multiple target frameworks creates multiple coverage.cobertura.xml files without any easy way to relate those back to the test project/target framework. (Can VSTest do this itself?) The output of dotnet test contains this information, but it would be complicated to parse.

Since coverlet is providing the filename of the VSTest attachments, would it be possible to (optionally) include the assembly name and target framework? For example, with junit.testlogger I can use dotnet test --logger "junit;LogFilePath=TestResults.{assembly}.{framework}.xml and have those placeholders filled in.

@daveMueller daveMueller added the untriaged To be investigated label Jan 7, 2022
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jan 23, 2022

Hi @gix,

we have it already for msbuild integration https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.msbuild.tasks/ReportWriter.cs#L25

for the collector integration we need to check, but we should get it from the runsettings for the "current" run(in case of more tfms we'll run more time) https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#runconfiguration-element (TargetFrameworkVersion)

To be aligned with msbuild we should use it "always", we don't have a way to provide dynamic patterns, also we don't have a way to change the report filename, at the moment if I recall well is a concat of

DefaultFileName https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.collector/Utilities/CoverletConstants.cs#L9
and report extension
https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.core/Reporters/CoberturaReporter.cs#L20

Concat part https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.collector/DataCollection/CoverageManager.cs#L110

I think that the first step would be align the behavior with msbuild.

Let me know if you're interested to take this contribution, not mandatory at all.

@MarcoRossignoli MarcoRossignoli added feature-request New feature request driver-collectors Issue related to collectors driver and removed untriaged To be investigated labels Jan 23, 2022
@daveMueller
Copy link
Collaborator

@MarcoRossignoli Can you elaborate this a bit? What if there is no runsettings file specified?

we should get it from the runsettings for the "current" run(in case of more tfms we'll run more time) https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#runconfiguration-element (TargetFrameworkVersion)

Can't we just also use coverlet.collector.targets like with MSBuild driver?

@MarcoRossignoli
Copy link
Collaborator

@daveMueller what you mean?

Target for collectors are used to inject coverlet path, but inside the collectors we don't have the current tfm running. I mean I'd don't see a way to flow the info inside the target to the datacollector that is the place where we generate the file.

There's always a runsettings generated "in memory" also if a user doesn't specify...that one contains the current tfm(and will merge with user config), the thing is that I think that inside the collector we don't have access to the whole config but only to our section and it's not clear if it's possible have access to it.

@daveMueller
Copy link
Collaborator

Ahh OK thanks I get it now. 👍

@daveMueller
Copy link
Collaborator

I created a PR with a prototype for this. Solutions can be discussed there #1299.

@github-actions
Copy link

This issue is stale because it has been open for 3 months with no activity.

@github-actions github-actions bot added the stale label Sep 10, 2023
Copy link

This issue was closed because it has been inactive for 9 months since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
driver-collectors Issue related to collectors driver feature-request New feature request stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants