Thanks for taking the time to contribute! We welcome and encourage contributions to this project.
Please read the contribution introduction for more information.
Pester is written in Powershell and C#. The C# solution requires .Net Framework SDKs and Developer Packs in order to compile, see links below how to install those prior to building.
The first time the repository is cloned, or when the C# code changes, the assemblies are built by running the following from the root of the repository:
.\build.ps1 -Clean
To build the Pester PowerShell module when the PowerShell code is changed run the following from the root of the repository:
.\build.ps1
✏ You can also build the module into a single file:
.\build.ps1 -Inline
This is how the real build is done, but it is hard to debug and change the code because it runs from the Pester.psm1 but you need to change it in it's respective file. Use this only when necessary.
To use the built module you can run the below from the root of the repository.
NOTE: If the assemblies have been changed and a previous version of the assemblies exist (loaded) in the session, then a new PowerShell session must be started for the new assemblies to be loaded again.
Import-Module .\bin\Pester.psd1 -Force
To get more information for the parameters that can be used, run the following:
Get-Help ./build.ps1 -Detailed
Pester has a C# Solution which requires .NET Framework SDKs and Developer Packs in order to compile. The targeted frameworks can be found in src\csharp\Pester\Pester.csproj
.
Download Link https://aka.ms/msbuild/developerpacks
Pester uses two types of tests:
- P tests (
*.ts.ps1
) written in the P module. These are used for unit testing the runtime itself and running acceptance tests for Pester - Pester tests (
*.tests.ps1
) for all functions in the module.
In Powershell, use test.ps1
. The scripts runs a build and imports required helper-functions like InPesterModuleScope
before starting.
Afterwards, each test can be run individually using Invoke-Pester.
Test.ps1 and optionally -skipPTests to skip the .ts.ps1 files.
test.ps1 can be run locally with the following parameters:
.\test.ps1 -File <filename>
To skip P tests:
.\test.ps1 -File <filename> -SkipPTests
To get more information for the parameters that can be used, run the following:
Get-Help ./test.ps1 -Detailed
The Azure Devops Pipeline azure-pipelines.yml file contains the code definition used for builds, unit and integration tests in the CI pipeline.
Within the pipeline, tests are executed against PS7 Core on a strategy matrix of machines, including Ubuntu 16.04, 18.04, macOS Mojave 10.14, Catalina 10.15, Windows Server 2016, 2019. Tests are also executed against PS6.2, PS4, PS3.
Documentation is available in the repo, the Pester wiki, and at https://pester.dev
Documentation is written in Markdown. Comment-based Documentation and parts of the documentation web site are generated using Docusaurus Powershell.
Multi-line examples added to comments should use fenced code.
https://docusaurus-powershell.netlify.app/docs/faq/multi-line-examples