Pester 

Time to learn Pester. Not so much a blog post as it is a reading/reference list.

What is Pester? 

“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

1
2
3
4
5
#Change directory into the desired location
cd C:\temp\my_PesterTests

#Create new test boilerplate
New-Fixture -Path C:\temp\my_PesterTests\Pester_Test -Name Pester_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:

1
2
3
cd C:\temp\my_PesterTests

Invoke-Pester 

Code Coverage refers to the percentage of lines of code that are tested by a suite of unit tests. - Code Coverage

Advanced docs 

Pester -TestCases 

Pester Tags