pester-cli-testing skill
Pester v5 프레임워크를 사용하여 PowerShell 스크립트, 함수 및 CLI 도구에 대한 단위, 통합 및 인수 테스트를 설정합니다.
- GitHub 스타
- 13
- 파일
- 3
- 마지막 커밋
- 2026년 11월 12일
- 라이선스
- MIT
- 허용된 도구
- —
pester-cli-testing skill은 무엇을 하나요?
pester-cli-testing은(는) agent skill입니다. Pester v5 프레임워크를 사용하여 PowerShell 스크립트, 함수 및 CLI 도구에 대한 단위, 통합 및 인수 테스트를 설정합니다.
skill의 SKILL.md에서 생성된 요약입니다.
pester-cli-testing skill 정보
이 SKILL은 pwsh 환경에서 작업하는 개발자가 PowerShell 스크립트, 함수 및 CLI 도구의 검증을 자동화할 수 있도록 지원합니다. Windows, Linux, macOS 전반에서 Pester v5 프레임워크를 사용하여 단위, 통합 및 인수 테스트를 구현하는 구조적인 방법을 제공합니다. 사용자는 Describe, Context, It 블록을 활용하여 복잡한 테스트 시나리오를 구성하고 Should 어설션을 적용하여 결과를 검증할 수 있습니다.
테스트 대상 코드가 PowerShell 기반인 경우 에이전트가 이 SKILL을 로드해야 합니다. 상태와 피스처를 관리하기 위해 BeforeAll 및 BeforeEach와 같은 라이프사이클 훅을 포함한 포괄적인 테스트 스위트를 생성합니다. 또한 명령 동작을 대체하는 Mocking, 특정 테스트 서브셋을 필터링하는 Tagging, 충분한 테스트 깊이를 보장하는 Code Coverage와 같은 고급 기능도 지원합니다. 지속적 통합(CI)을 위해 NUnit 또는 JUnit XML 출력을 생성하며, 파이프라인 신뢰성을 보장하기 위해 실패 시 0이 아닌 종료 코드를 반환하도록 구성할 수 있습니다.
agent가 수행할 수 있는 작업
- 1PowerShell 함수 로직 검증특정 함수가 예상된 문자열 출력을 반환하는지 확인하기 위한 테스트 파일을 생성합니다.
- 2외부 API 호출 모킹네트워크 의존적인 명령을 제어 가능한 구현체로 교체하여 오류 처리 또는 특정 응답을 테스트합니다.
- 3CI에서 코드 커버리지 모니터링코드 커버리지가 특정 백분율 미만으로 떨어지면 빌드가 실패하도록 구성을 설정합니다.
- 4카테고리별 테스트 필터링속도가 느린 테스트는 건너뛰고 통합 테스트와 같은 특정 테스트 서브셋만 실행합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
pester-cli-testing skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.플러그인에 pester-cli-testing skill 설치
/plugin marketplace add testland/qa /plugin install qa-cli-tools@testland-qa
Claude Code에 pester-cli-testing skill 설치
~/.claude/skills/pester-cli-testing/SKILL.md
$ npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing ~/.claude/skills/pester-cli-testingClaude Code (project)에 pester-cli-testing skill 설치
.claude/skills/pester-cli-testing/SKILL.md
$ npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing .claude/skills/pester-cli-testingCodex에 pester-cli-testing skill 설치
~/.agents/skills/pester-cli-testing/SKILL.md
$ npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing ~/.agents/skills/pester-cli-testingGemini CLI에 pester-cli-testing skill 설치
~/.gemini/skills/pester-cli-testing/SKILL.md
$ npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing ~/.gemini/skills/pester-cli-testingClaude.ai에 pester-cli-testing skill 설치
npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing pester-cli-testing && zip -r pester-cli-testing.zip pester-cli-testing # claude.ai → Customize → Skills → + → Create skill → Upload a skill → pester-cli-testing.zip
SKILL.md
GitHub에서 보기pester-cli-testing
Overview
Per pester-install, Pester is the standard PowerShell test framework for
unit, integration, and acceptance testing of scripts, functions, modules, and
CLI tools invoked from pwsh. It supports Windows PowerShell 3.0 - 5.1 and
PowerShell 6.0.4+ across Windows, Linux, and macOS. When the unit-under-test
is a shell script or binary on Linux/macOS, use bats-testing instead; Pester
is the correct choice whenever the subject or test is PowerShell.
Step 1 - Install
Per pester-install, Windows 10 / Server 2016+ ship with Pester 3.4.0
built-in. The bundled version cannot be updated via Update-Module alone
because its publisher certificate differs from the community-signed Gallery
version. Install Pester v5 side-by-side:
# Windows (5.1 or pwsh 7+): -Force enables side-by-side; -SkipPublisherCheck
# accepts the newer certificate
Install-Module -Name Pester -Force -SkipPublisherCheck
# Linux / macOS (pwsh 7+): no bundled version to conflict with
Install-Module -Name Pester
# Verify
Import-Module Pester -PassThru
Step 2 - First test file
Per pester-quick-start:
Test files must follow the *.Tests.ps1 naming convention. The outer
BeforeAll block dot-sources the script under test so its functions are
available to every nested block:
# Get-Greeting.Tests.ps1
BeforeAll {
. $PSScriptRoot/Get-Greeting.ps1
}
Describe 'Get-Greeting' {
It 'returns a greeting for the given name' {
Get-Greeting -Name 'Alice' | Should -Be 'Hello, Alice!'
}
}
Run with:
Invoke-Pester -Output Detailed .\Get-Greeting.Tests.ps1
Step 3 - Describe / Context / It
Per pqs, Context and Describe are nearly interchangeable. Use
Describe at the top level (function or CLI command name) and Context to
group scenarios:
Describe 'Invoke-Deploy' {
Context 'when the target environment is valid' {
It 'exits 0 and logs a success message' {
# ...
}
}
Context 'when credentials are missing' {
It 'throws a terminating error' {
# ...
}
}
}
Step 4 - Should assertions
Per pqs, Should is the assertion command. Common matchers:
$result | Should -Be 'expected' # strict equality
$result | Should -BeExactly 'Expected' # case-sensitive equality
$result | Should -BeLike '*partial*' # wildcard match
$result | Should -Match 'regex\d+' # regex match
$result | Should -BeNullOrEmpty # null or empty string/array
$result | Should -BeGreaterThan 0
{ risky-call } | Should -Throw # expects a terminating error
{ risky-call } | Should -Throw '*message*' # error message wildcard
$result | Should -Not -Be $null # negated form
Step 5 - BeforeAll / BeforeEach
Per pqs, lifecycle hooks load fixtures and reset state.
BeforeAll runs once per block; BeforeEach runs before every It:
Describe 'Get-Report' {
BeforeAll {
. $PSScriptRoot/Get-Report.ps1
$script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $script:TempDir | Out-Null
}
AfterAll {
Remove-Item -Recurse -Force $script:TempDir
}
BeforeEach {
# reset any per-test state here
}
It 'writes a report file to the output directory' {
Get-Report -OutputPath $script:TempDir
Test-Path (Join-Path $script:TempDir 'report.csv') | Should -BeTrue
}
}
Use $script: scope when a variable set in BeforeAll must be read inside
It blocks. Variables declared with plain $var in BeforeAll are not
visible inside It due to PowerShell scoping rules.
Step 6 - Mock
Per pester-mock:
"Mock mocks the behavior of an existing command with an alternate implementation."
Describe 'Send-Notification' {
BeforeAll {
. $PSScriptRoot/Send-Notification.ps1
Mock Invoke-RestMethod {
return @{ status = 'ok' }
}
Mock Write-Error {} # suppress error output in test runs
}
It 'calls Invoke-RestMethod once with the correct URI' {
Send-Notification -Message 'deploy done'
Should -Invoke Invoke-RestMethod -Times 1 -Exactly
}
It 'passes a ParameterFilter to scope the mock to specific arguments' {
Mock Get-Date { return [datetime]'2024-01-01' } -ParameterFilter {
$Format -eq 'yyyy-MM-dd'
}
$result = Get-FormattedDate
$result | Should -Be '2024-01-01'
}
}
Per pm, mocks placed in BeforeAll apply to all It blocks in the
enclosing Describe/Context; a mock inside an It block scopes only to
that test. Use -Scope to override. Should -Invoke verifies call count:
Should -Invoke -CommandName Invoke-RestMethod -Times 1 `
-ParameterFilter { $Uri -like '*api.example.com*' }
Per pm, $PesterBoundParameters (available since Pester 5.2.0)
replaces $PSBoundParameters inside mock script blocks.
Step 7 - Tags
Per pester-tags:
Tags can be applied to Describe, Context, and It blocks. Run a subset
by filtering on tags:
Describe 'Invoke-Deploy' -Tag 'Integration' {
Context 'slow path' -Tag 'Slow' {
It 'completes a full deployment cycle' -Tag 'E2E' {
# ...
}
}
}
# Run only Integration tests, excluding slow ones
Invoke-Pester $path -TagFilter 'Integration' -ExcludeTagFilter 'Slow', 'WindowsOnly'
Per pt, tag matching uses -like comparison, so wildcards work:
Invoke-Pester $path -ExcludeTagFilter 'Slow*', '*Only'
Step 8 - Invoke-Pester with PesterConfiguration
Per pester-config:
New-PesterConfiguration returns a typed configuration object. Cast from a
hashtable for concise setup:
$config = [PesterConfiguration]@{
Run = @{
Path = '.\tests'
Exit = $true # non-zero exit code on failure (required for CI)
}
Filter = @{
Tag = 'Unit'
ExcludeTag = 'Slow', 'WindowsOnly'
}
Output = @{
Verbosity = 'Detailed'
}
}
Invoke-Pester -Configuration $config
Key Run properties and their defaults (Run.Path, Run.ExcludePath,
Run.Exit, Run.TestExtension) are tabulated in
references/ci-and-config.md.
Step 9 - Code coverage
Per pester-coverage:
$config = New-PesterConfiguration
$config.Run.Path = '.\tests'
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Path = '.\src'
$config.CodeCoverage.CoveragePercentTarget = 75 # fail if below 75%
$config.CodeCoverage.OutputFormat = 'JaCoCo' # or 'CoverageGutters'
$config.CodeCoverage.OutputPath = 'coverage.xml'
Invoke-Pester -Configuration $config
Per pcov, Pester does not traverse directories automatically for
coverage; set CodeCoverage.Path explicitly when source files are not
co-located with tests.
Step 10 - Test result XML and CI
Per pester-results:
$config = New-PesterConfiguration
$config.Run.Path = '.\tests'
$config.Run.Exit = $true
$config.TestResult.Enabled = $true
$config.TestResult.OutputFormat = 'NUnitXml' # or 'JUnitXml'
$config.TestResult.OutputPath = 'testResults.xml'
Invoke-Pester -Configuration $config
Full CI pipeline definitions - a single cross-platform GitHub Actions matrix (with code coverage and artifact upload) and the Azure DevOps Publish Test Results task - are in references/ci-and-config.md.
Anti-patterns
| Anti-pattern | Why it fails | Fix |
|---|---|---|
Dot-sourcing the script under test inside It |
Re-executes on every test; slow and leaks state | Dot-source once in BeforeAll |
Using plain $var in BeforeAll, reading in It |
PowerShell scope: It does not inherit BeforeAll locals |
Use $script:var |
Mocking in It when needed across multiple tests |
Mock scopes to that single test only | Move mock to BeforeAll or BeforeEach |
Omitting Run.Exit = $true in CI config |
Pester exits 0 even on failures; CI pipeline passes on broken tests | Set Run.Exit = $true |
Setting CodeCoverage.Path = '.' without explicit paths |
Pester may miss source files not co-located with tests | Set CodeCoverage.Path to the source directory explicitly |
Using legacy Invoke-Pester -Script syntax |
Removed in Pester v5; breaks silently on older runners | Use PesterConfiguration with Run.Path |
Limitations
- Mocking scope is version-sensitive. Pester v5 scopes mocks to their
placement block (not the entire
Describe). Code written for v4 may need mock placement adjusted. - No built-in parallel execution. Pester v5 runs tests serially within
a session. Parallelism requires splitting test files across separate
pwshprocesses or using a CI matrix. - Non-PowerShell binaries. Pester can invoke any executable, but
assertion helpers are PowerShell-centric. For deep exit-code / stdout
testing of Unix binaries,
bats-testingis more idiomatic. - Windows PowerShell 5.1 vs pwsh 7+. Some Pester 5 features (e.g.
$PesterBoundParameters) require a minimum Pester patch level; pin the version in CI withInstall-Module -Name Pester -RequiredVersion 5.x.y.
References
- pester-install - compatibility, Windows side-by-side install,
cross-platform
pwshinstall. - pqs - quick-start,
BeforeAll,Describe/Context/It,Should. - pm -
Mock,ParameterFilter,Should -Invoke, scope rules,$PesterBoundParameters. - pc -
New-PesterConfiguration,Run,Filter,Output,Invoke-Pester -Configuration. - pcov -
CodeCoverage.Enabled,CoveragePercentTarget, formats, path scoping. - pr -
TestResult.Enabled,OutputFormat,OutputPath, Azure DevOps / AppVeyor CI notes. - references/ci-and-config.md - cross-platform
GitHub Actions matrix, Azure DevOps publish task,
Runproperty table. bats-testing- use for shell script / Unix binary testing; Pester is the correct choice when the subject or test is PowerShell.cli-output-conventions- what to assert on (stable formats, exit codes, stderr vs stdout contracts).
이 스킬의 파일
3pester-cli-testing skill 질문
Claude Code에 pester-cli-testing skill을 어떻게 설치하나요?
npx degit testland/qa/plugins/qa-cli-tools/skills/pester-cli-testing ~/.claude/skills/pester-cli-testing를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
pester-cli-testing skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
BeforeAll에서 정의한 변수를 It 블록에서 사용하려면 어떻게 해야 하나요?
PowerShell의 스코프 규칙 때문에 It 블록 내부에서 읽어야 하는 BeforeAll 설정 변수는 $script: 스코프 접두사를 사용해야 합니다.
PowerShell 대신 Linux/macOS에서 쉘 스크립트나 바이너리를 테스트해야 하는 경우에는 무엇을 사용해야 하나요?
Linux/macOS의 쉘 스크립트나 바이너리를 테스트하려면 Pester 대신 bats-testing을 사용해야 합니다.