Pester and PowerShell: TDD

There is obviously nothing special about Pester that encourages you down the TDD route. But assuming you start out with a test structure pattern that works for you, then with some trivial cosmetics, I find it is pretty good fun to do.

An example of some failing tests:

And following a fix to the code under test…

This is my overarching test runner:

For contriving a TDD approach out of this, you could:

clone my repository from GitHub here

From this location, delete the section below, so that you have a test but no SUT for it

When you execute RunAllTests.ps1, you see this:


You can then create nothing but the function name…


and execute RunAllTests.ps1 again…


, and eventually you get to a point when you have fully working code…

… and all tests passing:

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