The Pester Book Chapter Review (7)

Table of Contents – It Blocks

Today, we’ll review some of what was offered by the It Blocks chapter. Things, are getting interesting.

It turns out that It blocks are our main unit for testing. These blocks are the smallest blocks and belong inside a Describe and/or any Context blocks, if you’re using those. As they’re the smallest, it’s always best to keep them “simple, and as straightforward as possible.” The idea was that we should test everything independently of each other when we can, and that when we can’t, there needs to be a good idea as to why. That lead me to this write this Tweet today, where I questioned whether I should test all the permitted random password length values (4 – 35), that my random password function would accept in a single test, or one test — one It block — per value from 4 – 35. Take a look and let me know what you think as I’ve done both below. I haven’t actually seen any replies yet besides a few likes, and I still don’t know which I’ll end up using.

We also learned to have your It block throw a terminating error if an expectation isn’t met, the five possible results of an It block (passed, failed, etc.), using the Pending and Skip parameters on our It blocks, and finally about the Set-TestInconclusive option for It blocks that ensure a test is never run, under any circumstance.

Next we’re talking about Should. That should be interesting.

2 thoughts on “The Pester Book Chapter Review (7)

  1. Xiang

    hi,
    Maybe you can take a look at “-TestCases”, you could parameterize the inputs (4..35) and outputs (4..35)

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *