Skip to content

Conversation

@JerrettDavis
Copy link

I couldn't get the existing version to work with version 3.1.0 of coverlet.collector due to changes in how it generates tests.

This new version runs the tests via: dotnet test --collect:"XPlat Code Coverage" with an optional --settings <path>/coverlet.runsettings. And when it creates the test runs, it places them in folders with procedurally generated names.

To make the library work with both the old and new versions, I made some updates. First, I introduced a couple optional parameters called filename and discover-directory. If neither are set, it operates pretty much exactly as it did before. If discover-directory is set to true, it'll try to get the directory by checking the directory in the path specified in path. If it finds one, it gets appended to the path, and the filename is appended to that.

The documentation still needs to be updated.

@JerrettDavis
Copy link
Author

Correction on my part. While (as far as I can tell) the current version works with MSBuild integration, it does not work with vstest. My modifications will make the coverage reporter work for both MSBuild and VSTest. To use VSTest integration with my modifications, one simply needs to create a coverlet.runsettings file in the solution directory with the following contents:

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>opencover</Format>       
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

And the test CLI command needs to be updated to be:

dotnet test --collect:"XPlat Code Coverage" --settings coverlet.runsettings

@JerrettDavis JerrettDavis changed the title Updated to work with latest version of coverlet.collector Updated to work with VSTest Jan 13, 2022
@JerrettDavis
Copy link
Author

I'm currently looking at building a slightly different, wildcard-based version of this. Since actions can't use third-party libraries, I'm trying to come up with the most efficient way to do this easily.

@simon-k
Copy link
Owner

simon-k commented Aug 30, 2022

Thanks for the PR @JerrettDavis, and I'm sorry for not having a look at it before now.

I just want to check up on the status before I merge it and release a new version. Is it still valid functionality that you would like to have added or is this deprecated?

@JerrettDavis
Copy link
Author

Hi @simon-k. This code change should still be operation in its current state. I had hoped to expand it with pattern matching, but the submitted code changes do what is described in my original comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants