VS Code + Integrated Console + Pester = No Excuse Testing

Following up on an earlier post where I lightly touch on using the PowerShell Extension for the VS Code editor, I’d love to share how easy it is to Pester test and hopefully¬†convince you to start testing your code today! If you’re not familiar with me, I’m a huge fan of Pester. I mean this is such a great module that it’s baked into Windows! I Pester test EVERYTHING. Even things outside of my custom PowerShell functions… ETL executions, Jenkins job statuses, all kinds of things. I did a post about Pester testing SQL Server stuff, check it out if you haven’t seen it!

Using VS Code and the PowerShell extension, writing Pester tests has never been easier!!


Mocking SQL Results in Pester

A lot of my Powershell code interacts with databases and servers. Sometimes I’m grabbing a connection string, other times I’m check-pointing a long operation. When writing Powershell code that interfaces with databases, there’s usually a lot to test for. Well, it’s surprisingly simple to mock up SQL results using Pester.


The beginning

This is the story of how I started to love Ruby.

The Setup

I was working on adding integration tests to one of our main chef cookbooks, the one that installs and manages our SQL Server instances. Being a Windows shop, I used Pester and the Kitchen-Pester plugin.  I had a working set of Pester tests that verified all of the configuration settings on the server. Test-Kitchen passed when I ran the steps individually: