Table of Contents – Pester Concepts
As of this post, I’ve marched head first into Part I of The Pester Book.
It was a short chapter, as it included brief explanations of some Pester Concepts we’ll likely be spending more time with in our future. It explained Tests, as the basic unit of work within Pester. Remember, we’re on our way to learn how to test our PowerShell code with Pester. It also briefly touched on Mocks. This concept allows us to fake dependencies. The example used Get-Content. Instead of needing files from which we’d actually get the content, we can use mocking and have it appear as though we’ve returned the results we want, with the Get-Content cmdlet.
The chapter also included a brief discussion on assertions. It indicated that assertions are a core component of Pester (making a mental note of that). Assertions allow us to compare what should happen, and what does happen, when a specific part of our PowerShell executes.
Next, The Pester Book discussed scaffolding, and TestDrive. Scaffolding is referred to as a starting point for your tests. What it really seemed to be getting at, was the TDD philosophy. That’s the Test-Driven Development philosophy where you write (failing) tests first, then write the code to correct the tests. Without code in which to run your tests against, they’re going to fail, until you write the code that make those tests pass.
TestDrive is awesome. Or at first glance, it sounds like it will be. The TestDrive, drive is a FileSystem drive (like the C:\, D:\, etc.) that becomes available when a Pester test is running. This allows us to have a place to create file system objects while a Pester test is running, without worrying about negatively impacting a true filesystem where we don’t want to make changes.
This is getting good. Back soon.