Time to learn Pester. Not so much a blog post as it is a reading/reference list.
“Pester is the ubiquitous test and mock framework for PowerShell” or in other words, tests written to test the functions you have created without actually running those commands.
Are you asking yourself “why bother? just run the code and see if it works?” Yeah me too, but seems like everyone is doing it… so might as well jump off a bridge also, hopefully by the end I will see its value.
Create a new test
Invoke-Pester will execute the Powershell file ending with the name .Tests.ps1 against the other file that just ends in .ps1 (in the current directory).
In the terminal (not in the ISE part but at the >) execute something like this:
- Introduction to Testing Your PowerShell Code with Pester
- Unit Testing PowerShell Code with Pester
- Example using Ping
- More Examples and Explinations
- Example: Automate Infrastructure Testing with Pester
- Another good Example
Code Coverage refers to the percentage of lines of code that are tested by a suite of unit tests. - Code Coverage
- Testing Infrastructure - DSC & Pester
- Release Pipeline WhitePaper
- CI/CD pipeline for a new module