The Pester Book (retired)
The Pester Book (retired)
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
-
Pester Concepts
-
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
-
Design Practices
-
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…..
-
Why Code Coverage?
-
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
-
Recipe: Testing for Live Conditions
Other books by these authors
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them