Table of Contents – Describe Blocks
And, here we go. It’s time, to start testing with Pester. Or rather, it’s time to really start making our way toward that end goal. We’re going to start that with Describe blocks, also known as, “…the outer container for a group of tests.” It’s how this whole testing thing begins, and it looks like this:
Describe { }
As stated, we need to think of a Describe block as a single shared scope for everything it contains. This means that the TestDrive PSDrive is available to all the tests within the Describe block. But what’s the TestDrive, right? I think it may have been mentioned previously, but it’s a drive — a PSDrive — that exists while the Describe block is executing. It’s a place to safely create folders and files during testing without the fear of making any mistakes against actual files and folders. There was also a mention of Mocks only existing while the Describe was running; I suspect we’ll get to these in time.
This chapter also touched on a few other valuable concepts that we’re going to be grateful we’ve learned. These included tagging. The Describe keyword actually has a Tag parameter that can be used to help separate whether, or not, a Describe block will run when using the Invoke-Pester function — don’t think we’ve talked about that one yet. Do keep in mind that if you don’t include a tag for a Describe block, that it’s always going to execute when the test is run.
This chapter also clued us in to upcoming topics, which included the Context block, It blocks, and BeforeAll, BeforeEach, AfterAll, and AfterEach. Keep reading; I’m about to do the same.