The Pester Book (retired)
The Pester Book (retired)

Retired

This book is no longer available for sale.

The Pester Book (retired)

This book is 70% complete

Last updated on 2017-02-20

About the Book

This book has been retired, and Adam is now working on it on his own. You can find the “replacement” book at https://leanpub.com/pesterbook, and Adam can be contacted there (on the “Email the Author” section) or on Twitter @adbertram.

Table of Contents

  •  
    • About This Book
    • About the Author
    • Foreword
    • Feedback
    • Code Samples
    • Introduction
      • Testing as Institutional Memory
      • Testing Drives Better Modularization
      • Tests as Functional Specifications
      • Tests in Automated Build Pipelines
      • Automated Testing!
      • Where We’re Not Going
  • Part 1: Meet Pester
    • Pester Concepts
      • Tests
      • Mocks
      • Assertions
      • Scaffolding
      • TestDrive
    • Designing for Testing
      • Input is Via Parameters
      • Output is Via the Pipeline
      • Actions Aren’t Output
      • Tightly Scoped Commands are Easiest to Test
      • A Word for DSC Resource Authors
    • Describe and Context Blocks
      • A Describe is a Scope
      • A Describe Can be Tagged
      • A Describe Contains…
    • Before and After Blocks
    • It Blocks
      • Examples
      • The Actual Test
    • Should
      • Be and BeExactly
      • BeLessThan, BeGreaterThan
      • Wildcard Comparisons: BeLike, BeLikeExactly; Match, MatchExactly
      • Object Type: BeOfType
      • Errors: Throw
      • Objects Exist: Exist
      • Strings in Files: Contain, ContainExactly
      • Nothing: BeNullOrEmpty
      • BeIn (an Array)
      • Remember: Should is a Command That Can Throw Exceptions
    • Test Cases
      • Creating Tests for Different Parameters
      • Using the TestCases parameter
      • Using the Test Name Token
      • Test Cases Have Many Uses
    • Mocks
      • Mocking Specific Object Types
      • Mock Scope
      • Module-Level Mocks
      • Parameter Filters
      • Verifying Mocks
    • The TESTDRIVE: Drive
      • Referencing Test Drive as a PSDrive
      • Referencing TestDrive as a Variable
  • Part 2: Using Pester
    • Design Practices
      • Testing is a Forever Thing
      • Dealing with Modules and Dot-Sourced Scripts
      • The Input/Execution/Output Pattern
      • Naming Conventions
      • Tagging
    • Adding Tests For a Function
      • Understand the Subject
      • Designing Tests
      • Writing the Test
      • Future Iterations
      • Comparing to Warren’s Tests
      • Wrapping Up
    • Adding Tests - Again
      • The Code
      • Analyzing the Code
      • Refactoring the Code for Testability
      • Limiting Function Input
      • Writing the Tests
      • Wrapping Up
    • Working with Pester Output
    • Infrastructure Validation
      • Infrastructure Validation in Pester
      • Analyzing the Code
      • Getting Testing Dependencies in Place
      • Prototyping the Tests
      • Writing the Infrastructure Tests
      • Dependencies
      • Building Dependency Discovery Code
      • Adding Dependency Checking to Tests
      • Switching it Up
    • Mocking the Unmockable
      • Methods
      • Wrapping Up
    • Cross-Platform Pester
    • Testing GUI Scripts
    • Troubleshooting Tests
  • Part 3: Code Coverage
    • Why Code Coverage?
      • Code Coverage Metrics
      • So… Why Code Coverage?
      • The Test Case Tie-In
    • Using Pester to Measure Code Coverage
      • A Simple Code Coverage Test
      • Getting Granular with Code Coverage
    • Improving Code Coverage
      • Start Here
      • Analyzing Code Coverage
    • A Pester Case Study
      • Background
      • TO BE CONTINUED…..
  • Part 4: Pester Cookbook
    • Recipe: Testing for Live Conditions
      • The Recipe
      • The Background
    • Recipe: Testing Scheduled Tasks
      • The Recipe
      • The Background
    • Recipe: Testing for Installed Software
      • The Recipe
      • The Background
    • Recipe: Ensuring all Functions in a Module Have Tests
      • The Recipe
      • The Background
    • Recipe: Testing Scheduled Tasks
      • The Recipe
      • The Background
    • Recipe: Testing External Applications
      • Testing Exit Codes from EXE Files In Scripts
      • The Background
      • Testing Exit Codes from Standalone EXE files
      • The Background
    • Recipe: Common Tests for Functions and Modules
      • The Recipe
      • The Background
    • Recipe: Testing Script Blocks
      • The Recipe
      • The Background
    • Release Notes

About the Authors

Don Jones
Don Jones

Don Jones has been in the IT industry since the mid 1990s, and has been a recipient of Microsoft's "Most Valuable Professional" Award since 2003. He's a co-founder of PowerShell.org and The DevOps Collective, and a Curriculum Director for online video training company Pluralsight. Don authored some of the first books ever published for Windows PowerShell, and is the co-author of Learn Windows PowerShell in a Month of Lunches, the bestselling entry-level book for PowerShell. Don's a sought-after speaker at technology conferences like Microsoft Ignite, TechMentor, and many more. You can find him on Twitter @concentratedDon, or on his website, DonJones.com. 

Adam Bertram
Adam Bertram

Adam Bertram is an Senior Automation Engineer, technical writer, trainer, and presenter. Adam specializes in consulting and evangelizing all things IT automation. Adam is a Microsoft Windows Cloud and Datacenter Management MVP focused on the PowerShell language and various DevOps tooling in the Microsoft ecosystem. He authors IT pro course content for Pluralsight, is a regular contributor to numerous print and online publications and presents at various user groups and conferences.

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors and publishers use Leanpub to publish amazing in-progress and completed ebooks, just like this one. You can use Leanpub to write, publish and sell your book as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub