powershell-pester-test-generator

Generate Pester 5.x test files for existing PowerShell functions with parameter, pipeline, and edge-case coverage.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/MartiXDev/ai-dev-strategy --skill powershell-pester-test-generator-martixdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: powershell-pester-test-generator
Source: https://github.com/MartiXDev/ai-dev-strategy/tree/main/custom/PowerShell/skills/powershell-pester-test-generator
Command: npx skills add https://github.com/MartiXDev/ai-dev-strategy --skill powershell-pester-test-generator-martixdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Pester.

What problem does it solve? Existing PowerShell functions often lack unit tests, making refactoring risky and leaving bugs undetected. This Skill retrofits comprehensive Pester 5.x test suites onto existing functions so you get a safety net without writing every test by hand. ## Core Features & Use Cases - Structured Test Generation: Produces complete test files with BeforeAll, Describe, Context, and It blocks following Pester 5.x conventions. - Coverage of Key Scenarios: Generates tests for parameter validation, mandatory parameters, ValidateSet rules, pipeline input (single and multiple values), ShouldProcess, error handling, and edge cases like Unicode and special characters. - Use Case: You inherit a legacy PowerShell module with no tests. Point this Skill at Get-FileMetadata.ps1 and receive a ready-to-run Tests/Get-FileMetadata.Tests.ps1 file covering happy paths, validation failures, and pipeline behavior. ## Quick Start Generate Pester 5 tests for my PowerShell function Get-UserReport including parameter validation, pipeline, and edge case coverage.

Frequently Asked Questions about powershell-pester-test-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Pester tests for existing PowerShell functions?

Analyze the function's parameters, pipeline support, and validation attributes, then create a .Tests.ps1 file with BeforeAll to import the function, Describe blocks per function, and Context blocks grouping validation, happy path, pipeline, and edge case tests.

How to test PowerShell pipeline input with Pester?

Pipe values directly into the function inside an It block, such as 'value' | Get-MyFunction, and assert on the result. Test both single values and arrays to verify ValueFromPipeline and ValueFromPipelineByPropertyName behavior.

Does Pester 5 support code coverage for PowerShell scripts?

Yes, Pester 5 supports code coverage through New-PesterConfiguration. Set CodeCoverage.Enabled to true and point CodeCoverage.Path at your source scripts, then run Invoke-Pester with the configuration object.

What is the difference between BeforeAll and BeforeEach in Pester 5?

BeforeAll runs once per Describe or Context block and is preferred for expensive setup like module imports. BeforeEach runs before every individual It block and suits per-test state that must be reset.

When should I not use a Pester test generator?

Avoid retrofit generation when writing new functions, where test-driven development with tests written first is more appropriate. Generated tests are best for legacy code, pre-refactoring safety nets, and standardizing coverage.