Perster for PowerShell
Pester is a TDD unit testing framework for PowerShell with build in Mocking features. Think Google Test & Google Mock combined but for PS, not C++
Pester can also do Code Coverage but this is slightly limited because of the facilities offered by the PS engine (Uses PSBreakpoints which doesn’t capture all code execution.)
C.F.
- Get started with Pester
- TestDrive: is a PowerShell PSDrive for file activity limited to the scope of a single Describe or Context block.
- Invoke-Pester
- Code Coverage
- Mocking with Pester
- Should is a command that provides assertion convenience methods for comparing objects and throwing test failures when test expectations fail. Should is used inside It blocks of a Pester test script.
- Mocks the behavior of an existing command with an alternate implementation.
- Describe creates a logical group of tests
- Context, provides logical grouping of It blocks within a single Describe block.
- It Validates the results of a test inside of a Describe or Context block.
For example (Note back ticks so parenthesis can start on new line.):