
#POWERSHELL PESTER EXAMPLES CODE#
Note: All the code for this post can be found here. This may (ok, it will) influence how I use the Pester framework which is really more leaning towards RSpec than Cucumber or SpecFlow (both being Gherkin family frameworks).

Or is it?ĭisclaimer: I’m a BDD enthusiast and specifically I ‘m very fond of Specification by Example and the Gherkin syntax. It often deals a lot with external dependencies such as services and IO which are often hard to get under test. PowerShell is often used in some sort of configuration scenario, may it be in a build/setup scenario for SharePoint or a deployment framework for your web application etc.

Don’t let the word “script” or “shell” fool you, it’s still code. However when you’re constructing something that will survive over time and that others may use and improve, testing is extremely useful. Sometimes it definitely a place for ad-hoc code that just just executes once or twice just to accomplish something for the time being.

I do believe, much like in any other language, that sometimes you don’t have the need to test your code (say what!?). So why on earth should you test your PowerShell scripts, are they not meant to be ad-hoc? This blog post is meant as a quick introduction to what I think are the key take-aways of Pester and how I use it. Pester is a BDD inspired testing framework for PowerShell just like Jasmine is on the JavaScript side and RSpec is on the Ruby side for example (I do believe that JavaScript is one of the best comparisons for PowerShell though, it being a scripting language and all).
