Skip to content

Instantly share code, notes, and snippets.

@dlwyatt
dlwyatt / example.Tests.ps1
Created February 14, 2015 13:25
Pester Example
# Import the stuff you'll be testing. Could be dot-sourcing a ps1 file here, importing a module, whatever you need.
# If importing a mdoule, make sure you've only got one copy of it imported, or weird things can happen when you start
# to get into mocking.
Remove-Module [S]omeDscResource
Import-Module $PSScriptRoot\SomeDscResource.psm1
# All of the Pester tests in a script must go inside a Describe block; you can mave many Describe blocks in the same
# script, if you like. Make sure to put the opening brace on the same line as Describe, since this is just a function
# pretending to be a keyword; no assistance from the parser allowing us to put opening braces on their own lines.