Beyond Pester 101: Applying testing principles to PowerShell

By Glenn Sarti

Elevator Pitch

We see a lot talks on testing PowerShell with Pester, but are the tests we write good tests? What makes a test “good”? How do we measure how effective our tests are? This talk will help you answer these questions, including why testing is important and how to apply these principles to your project.

Description

We see a lot talks on testing PowerShell with Pester, but are the tests we write good tests? What makes a test “good”? How do we measure how effective our tests are? This talk will cover testing philosophies and practices that can help you answer these questions, including why testing is important, different types of testing, and how to apply these principles to your project.

Topics:

Why test?

  • Identifying why you’re testing is key, as it affects how you write tests and measure their impact. Is cycle time high priority? Or coverage?

Different types of testing

  • Using the testing pyramid as a guide
  • Implementation vs Behavioural testing - pros, cons, and when to use each

Measuring your testing

  • Having a test suite is all well and good but how do feed and care for it?
  • Measure your tests - pass/fail, time, failure counts etc.

Grooming your test suite

  • When and how to groom your suite. Move tests up and down the pyramid. Delete tests that yield no value.

When not to test!

  • Every test your write requires maintenance and resources. You need to make sure the test is worth it.

Each section will be backed up with practical examples and advice on how to apply this to real world PowerShell projects

Notes

While working at Puppet as developer on the Windows team, I see a large range of Open Source projects, and the testing requirements for each changes. For example Puppet itself has over 28,000 unit tests, while some smaller projects have only 20. Grooming and caring for your tests is very important when you either scale the size of the project (Number of lines) or the increase the number of people contributing. I see these parallels in the PowerShell community too. Many talks focus on how to use Pester but not as much on the more higher level testing principles, which are becoming more important as the PowerShell community grows and matures.

In this talk I hope to introduce people to think about testing in depth; that is, it’s more than just writing a Pester test. I also want to affirm that these skills are transferable to almost any programming language so learning this is good for your career too.