Added detailed code coverage. #920
Conversation
…line covered or missed numbers.
|
@jonkeda, Please check the result of tests - your code is not compliant with the style rules defined for Pester. |
it-praktyk
left a comment
There was a problem hiding this comment.
Please add a required help for the added parameter.
| [ValidateSet('JaCoCo')] | ||
| [String]$CodeCoverageOutputFileFormat = "JaCoCo", | ||
|
|
||
| [Switch]$DetailedCodeCoverage = $false, |
There was a problem hiding this comment.
The newly added switch is not described in the comment based help.
…e switch is on then the CodeCoverage parameters of the Describe parts will be used for code coverage.
|
Fixed the style errors and added a comment on the DetailedCodeCoverage switch parameter. Currently it fails localy on the release version tag. Also added a -CodeCoverage parameter to the Describe function. If the DetailedCodeCoverage switch is on then the CodeCoverage files are collected by reading the parameter from the describe function. For instance add the following to the Coverage.Tests.ps1 file: -CodeCoverage $PSScriptRoot\Coverage.ps1 and it will cover this file also. |
|
@jonkeda it is a bit difficult to test with test runner, as you have added an additional flag. I have just tried to setup VSTS to build Pester with Pester Test Runner, but a lot of the test failed, so I think it will take me a couple of hours to figure out how to get a "beta" version of Pester into a VSTS build. I have a few other projects on my todo list, but I will return this soon as it seems quite cool :-) |
jonkeda
left a comment
There was a problem hiding this comment.
The change requested have been made.
| if ($DetailedCodeCoverage) | ||
| { | ||
|
|
||
| $fileName = "" |
There was a problem hiding this comment.
The variable assigned but not used. Can you check why?
|
Any reason that DetailedCodeCoverage isn't just the default output when CodeCoverageOutputFile is specified? It seems like an unnecessary switch. I'd also suggest still outputting to the screen as it's quite handy to see at a glance what has been missed if you're not using the JaCoCo reader. |
|
|
@it-praktyk Is it really a breaking change? I haven't tested it yet. But to me the switch also seems unnecessary. @ChrisLGardner have you tried it? I don't have experience with the jacoco format? Can we make the detailed format the default, or would it break existing builds? |
|
From the testing I did when I first found this issue I didn't see any breaking change, at least on the Azure pipelines side of things. Based on the OP it doesn't seem like it'll have any effect extra for when using tools like jacoco reader. I'd need to do more thorough testing but I can't see why the detailed view can't be the default, especially if tools like codecov.io can make use of it too.
…________________________________
From: Jakub Jareš <notifications@github.com>
Sent: Saturday, September 29, 2018 3:41:27 PM
To: pester/Pester
Cc: Chris Gardner; Mention
Subject: Re: [pester/Pester] Added detailed code coverage. (#920)
@it-praktyk<https://github.com/it-praktyk> Is it really a breaking change? I haven't tested it yet. But to me the switch also seems unnecessary. @ChrisLGardner<https://github.com/ChrisLGardner> have you tried it? I don't have experience with the jacoco format? Can we make the detailed format the default, or would it break existing builds?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#920 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AQDqFv7O4AJb3O_VBII5_ub6xjD2jVPUks5uf4aXgaJpZM4P_UBi>.
|
|
@ChrisLGardner would be great if you could test it a bit more 👍 |
|
@jonkeda Thanks I merged it as is, if we figure out the change is not breaking I will just make it the default without the |
|
After generating coverage report XML file for pester tests, How to publish jacoco report on jenkins ? |
|
@nitinkshirsagar I haven't worked with Jenkins in few years, but I would say you need a plugin, such as this one, and give it path or wildcarded path to your code coverage report. |
Hi mr Wyatt,
I added a switch -DetailedCodeCoverage to the Invoke-Pester command. If this switch is on then the JaCoCo codecoverage file will have additional data. Per sourcefile a line counter and each line covered or missed numbers are added to the export of de JaCoCo codecoverage file. Furthermore the lines will not be printed to the console.
The JaCoCo reader can be used to view the covered and missed percentages and show the sourcefiles with red and green line coloring.
This tool can be found here: https://visualstudiogallery.msdn.microsoft.com/14da4aa2-e833-4f1d-8765-0d3d79fd08a3?redir=0
One unittest was added to check the creation of the right data.
As an example run the following:
Next step is to add the code coverage reader functionality to the PoshTools.
Let me also thank you for Pester.
Kind regards,
Daan Jonkers