Pester provides a framework for running unit tests to execute and validate PowerShell commands from within PowerShell. Pester consists of a simple set of functions that expose a testing domain-specific language (DSL) for isolating, running, evaluating and reporting the results of PowerShell commands.
Pester tests can execute any command or script that is accessible to a Pester test file. This can include functions, cmdlets, modules and scripts. Pester can be run in ad-hoc style in a console or it can be integrated into the build scripts of a continuous integration (CI) system.
Pester also contains a powerful set of mocking functions in which tests mimic any command functionality within the tested PowerShell code.
You can download the latest Pester version from GitHub and copy it to a folder in $env:PSModulePath – but it’s more convenient to use a packaging solution like PSGet or Chocolatey.
Here is an example how you can install Chocolatey, a software management solution (in case you haven’t done it yet – line 1), and then install Pester (line 2).
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) choco install pester -y
Notes
Chocolatey – Software Management for Windows
Upgrade Pester
Install-Module -Name Pester -Force
Upgrade Chocolately
choco upgrade all -y