Skip to content

Conversation

mschnelte
Copy link

Adding support for microsoft's code coverage.
Can be enabled via options.
Coverage settings are controlled via fineCodeCoverageSettings.xml file that is created on first test run if ms code coverage option is enabled.

@tonyhallett
Copy link
Collaborator

@mschnelte Thanks. WIll have a look tomorrow.

@tonyhallett
Copy link
Collaborator

@mschnelte Adding some commits now

@tonyhallett
Copy link
Collaborator

@mschnelte

There are additional issues with this pr.

FCC currently outputs cobertura files to a specific directory - this should follow suit.

It does not work well with a test project that provides its own run settings - of course you can set the option to false - but then you are not getting the benefit. The code should only be creating run settings when required and should be able to collate output files for either scenario.

PrepareCoverageProjectsAsync is being unnecessarily called.

At the moment only the test assembly is excluded ( all in one runsettings to be used by all test projects ). FCC does more than that.

I have the code that I used to demonstrate the idea ( #214 (comment) ) that can be merged with your existing code. It also refactors FCCEngine so that FCCEngine is ignorant to ms coverage.

Please don't add any further commits until I have addressed these issues ( tomorrow now ).

@mschnelte
Copy link
Author

At the moment only the test assembly is excluded ( all in one runsettings to be used by all test projects ). FCC does more than that.

I am aware of it. But aren't the settings in FCC coverlet specific? If you feel it's worth the trouble mapping them feel free to do this. For me it would be good enough to edit the fineCodeCoverage.xml template as stated in the description of the PR.

What I do not like about the FCC options is the fact that they are not solution specific. Using the template for that would make it solution specific. I would favor that over global options. But of course nothing is stopping us to mix both approaches.

I have the code that I used to demonstrate the idea ( #214 (comment) ) that can be merged with your existing code. It also refactors FCCEngine so that FCCEngine is ignorant to ms coverage.

What you are showing there was how I started. Simply collecting the coverage files if runsettings are set. I guess that is a use case that should be supported. But don't forget that runsettings might not contain a CoverageCollector - and I guess that is currently the majority of runsettings given the fact how new the microsoft code coverage support is. In those cases the user's runsettings might need to be altered to include coverage. One workflow could be:

  1. Test are started
  2. fcc detects runsettings without a code coverage collector
  3. fcc asks the user if the existing runsettings shall be enhanced to include code coverage collectors
  4. optional: old runsettings are backed up

@tonyhallett
Copy link
Collaborator

Sorry for not responding today but I have been dotPeek-ing the test explorer source looking for the optimum solution.

@mschnelte
Copy link
Author

Sorry for not responding today but I have been dotPeek-ing the test explorer source looking for the optimum solution.

No worries. I will most probably not be very responsive either until beginning of next week.

@tonyhallett
Copy link
Collaborator

Hopefully tomorrow I will be able to show the changes that I have made.

@tonyhallett
Copy link
Collaborator

tonyhallett commented Mar 17, 2022

There is more that I will do in the next couple of days. Committing now that you can see where I am going with this.

This now works if the dev provides runsettings or not.

If not then runsettings are created for each project with includes / excludes being determined in a similar manner to pre ms code coverage. I have added new FCC options that can be provided globally or on a project basis as before. ( I will add the concept of solution options that will apply to ms code coverage and the old way soon ).

If desired a template can be provided ( found by naming convention in project / solution folder ) that will be used with string replacement as before.

If the dev provides runsettings this can also participate in string replacement.

@tonyhallett tonyhallett merged commit ca33352 into FortuneN:master Mar 29, 2022
@github-actions
Copy link

released v1.1.170 and available on marketplace

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.

3 participants