Skip to content
📔 Create Coveralls.io Coverage Reports for your PowerShell Modules
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
assets
bin
docs
resources/TestModule
src
tests
tools
.gitignore
LICENSE
README.md
appveyor.yml

README.md

AppVeyor branch AppVeyor tests branch Coveralls github PowerShell Gallery PowerShell Gallery

forthebadge forthebadge

General

PSCoverage is an interface for coveralls.io. It enables you to run your known pester tests and its coverage report. Furthermore it formats the coverage report and uploads it to coveralls.io.

To get started read the about_PSCoverage page.

Installation

PowerShellGallery.com (Recommended Way)

  • Make sure you use PowerShell 5.0 or higher with $PSVersionTable.
  • Use the builtin PackageManagement and install with: Install-Module PSCoverage -AllowPrerelease
  • Done. Start exploring the Module with Import-Module PSCoverage ; Get-Command -Module PSCoverage

Manual Way

  • Take a look at the Latest Release page.
  • Download the PSCoverage.zip.
  • Unpack the Zip and put it in your Powershell Module path.
    • Don't forget to change the NTFS permission flag in the context menu.
  • Start with Import-Module PSCoverage

Usage

Navigate to your module/ repository root. Your module structure needs to be like this:

~\src\
      Private\
              Invoke-Foobar.ps1
      Functions\
      External\
~\tests\
        Private\
                Invoke-Foobar.Tests.ps1
        Functions\
        External\
~\ModuleManifest.psd1
~\ModuleScript.psm1

1. First you need a list of all your src files:

$srcFiles = Get-ChildItem -Path ".\src\*.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'

2. Next you need a list with all your pester tests files:

$testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'

3. The simplest way to get you code coverage is by creating it with your unit tests. This avoids rerunning all the test with PSCoverage:

$TestResults = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -PassThru

4. And then passthru the code coverage to create a new report:

$CoverallsIOReport = New-CoverageReport -CodeCoverage $TestResults.CodeCoverage -RepoToken '123456' -ModuleRoot $PWD

5. Finally we can upload the coverage report to coveralls.io:

Publish-CoverageReport -CoverageReport $CoverallsIOReport
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.