Search code examples
powershellpester

Pester - How to output Pester code coverage report in JaCoCo format?


I'd like to output Pester's code coverage data in JaCoCo format. The Pester repo indicates this is possible: https://github.com/pester/Pester#code-coverage

But I can't find any info about how to actually do it in the docs: https://pester.dev/docs/usage/code-coverage

I tried using the command below to see if the outputted XML includes any coverage data but it doesn't.

Invoke-Pester -Tag 'Unit' -CodeCoverage '**/*.psm1' -OutputFile Test-Pester.XML -OutputFormat NUnitXML

Is this possible using Pester 3.4.0? If no, how is it done using the latest versions of Pester?


Solution

  • Looks like it's not possible in Pester 3.4.0, but is possible starting somewhere in v4.

    The docs here outline the options: https://pester.dev/docs/commands/Invoke-Pester#default-default

    An example usage could be:

    Invoke-Pester -Tag 'Unit' -CodeCoverage '**/*.psm1' -CodeCoverageOutputFile 'Pester-Coverage.xml' -CodeCoverageOutputFileFormat JaCoCo