-
Notifications
You must be signed in to change notification settings - Fork 8
Pester Task
The Pester
task runs tests using the PowerShell testing framework Pester.
The task supports Pester version 5 and later. By default the latest version of Pester 5, i.e. 5.*
, is used to run your
tests. Use the Version
property to use a specific version of Pester, wildcards supported. If you need to use an older
version of Pester, see the Pester3 and
Pester4 tasks.
Pass a dictionary of parameters to the Configuration
property to specify the [PesterConfiguration]
object to use.
This dictionary is passed to New-PesterConfiguration to
create the [PesterConfiguration]
object that will be passed to Invoke-Pester
. The [PesterConfiguration]
is how you
control what Pester will do via parameters such as Run.Path
, Run.ExcludePath
, TestResults.Enabled
.
Pass a dictionary of parameters to the Container
property to specify the [ContainerInfo]
object to use. This
dictionary is passed to New-PesterContainer to create the
[ContainerInfo]
object that will be passed to Invoke-Pester
. The [ContainerInfo]
object is used to pass
parameter-input to Pester .Tests.ps1
files with a param()
block.
Test reports are saved to the output directory in NUnit XML format. The report files are named
pester+RANDOM_STRING.xml
, where RANDOM_STRING
is a random strings of characters.
-
AsJob
: by default, the task runs Pester in Whiskey's private scope in the same PowerShell session/process that the Whiskey build was started with. To run Pester tests in an new, independent PowerShell process via a PowerShell job, set this totrue
-
Configuration
: a dictionary of parameters passed to New-PesterConfiguration to create the[PesterConfiguration]
object that's passed toInvoke-Pester
. -
Container
: a dictionary of parameters passed to New-PesterContainer to create the Pester[ContainerInfo]
object that's passed toInvoke-Pester
. -
Version
: the version of Pester to use, wildcards supported. Defaults to the latest version of Pester5
, i.e.5.*
.
Build:
- Pester:
Configuration:
Run:
Path: 'Test\*.Tests.ps1'
Demonstrates how to run Pester tests. In this case, all the tests in files that match the wildcard Test\*.Tests.ps1
are run.
Build:
- Pester:
Configuration:
Run:
Path: 'Test\*.Tests.ps1'
ExcludePath: '*.NotATest.ps1'
Demonstrates how to use the Pester Configuration's ExcludePath
property to exclude tests from running. In this example, all tests in the Tests directory that end in ".Tests.ps1" will be run, except those that end in ".NotATest.ps1".
Build:
- Pester:
Configuration:
Run:
Path: 'Test\*.ps1'
TestResult:
Enabled: true
Demonstrates how to use the Pester Configuration's TestResult
property to produce test results for all the tests in files that match the wildcard "Test*.ps1".
Build:
- Pester:
Configuration:
Run:
Path: 'Test\*.Tests.ps1'
Version: 5.3.*
Demonstrates how to pin Pester to a specific version, the latest "5.3" patch version in this case.
- Common Task Properties
- AppVeyorWaitForBuildJob
- CopyFile
- Delete
- DotNet
- Exec
- File
- GetPowerShellModule
- GitHubRelease
- InstallNodeJs
- LoadTask
- Log
- MergeFile
- MSBuild
- NuGetPack
- NuGetPush
- NuGetRestore
- NUnit2
- NUnit3
- Parallel
- Pester
- Pipeline
- PowerShell
- ProGetUniversalPackage
- PublishBitbucketServerTag
- PublishBuildMasterPackage
- PublishNodeModule
- PublishPowerShellModule
- PublishProGetAsset
- PublishProGetUniversalPackage
- SetVariable
- SetVariableFromPowerShellDataFile
- SetVariableFromXml
- TaskDefaults
- Version
- Zip