Much TODO with Sapien PowerShell Studio 2016 and Pester

I’ve been working a lot with Peter lately, and as I’ve blogged about before I use Sapien’s PowerShell Studio tool. The new 2016 version has an interesting new capability that while it may seem small, works extremely well when developing Pester tests.

When I create a Pester test, for example for a function, I outline all the things I need to test. Once I’ve created the list, I then go into my test script, and create It statements for each test.

Pester has a switch you can pass to It called –Pending. This will cause Pester to skip over the test. This allows you to stub out needed tests without them interfering with your code. Pester itself will even display pending tests in its output.

    It ‘is a test yet to be implemented’ –Pending {

    }

Knowing you have a test to implement, and being able to quickly find where that code is, are two different things. Tests can get rather long rather quickly. I also admit I don’t always develop the tests linearly. For example, I may develop part of a unit test, then copy that code lower in the script and adapt it for the acceptance test. Then go back up to the next It assertion I need to work on.

That’s where a nifty little feature in the new 2016 version of PowerShell Studio comes in handy. When you add a #TODO: statement (pound sign TODO followed by a colon), it will appear in the navigation drop down in the PowerShell Studio editor.

Here’s a little example. In the screen capture below, you see I have the first test, which has been implemented. Following are two more tests using the –Pending switch.

image

 

Here’s a slightly closer view. You can see the various #TODO: comments. When I click in the navigation drop down, these TODOs show up, allowing me to jump to them easily.

image

This has been surprisingly useful when working with Pester. While the example shown above seems trivial, some of my tests are hundreds of lines long. Being able to quickly navigate to tests I still need to implement keeps my workflow going ahead at a good pace, and keeps me from getting frustrated trying to find the next test I want to implement.

I also have to say the new dark color theme leaves me all warm and fuzzy inside. Smile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: