-
Notifications
You must be signed in to change notification settings - Fork 32
CreateATest
Every test must implement a few bits of logic.
It must have two properties: [string]$Target
and [scriptblock]$Should
. It can optionally implement [string]$Property
and [string]$Qualifier
. If your function has any more than those 4 parameters, it will likely break unless you take special measures to deal with them.
- Target is the name or unique identifier of object you are testing.
- Should is the assertion using Pester Should syntax.
-
Property Will add
| Select-Object -ExpandProperty $Property
to the TestExpression. - Qualifier could be used to further filter the Target however you would like.
It must call Get-TestParam
with at least the following properties.
- TestName is the type of test. i.e. File, Service
- TestExpression is a scriptblock that will be executed to get an object to test.
- @PSBoundParameters Splat the PSBoundParameters automatic variable.
Optionally, you may pass a FriendlyName parameter. This is used when generating the Pester It Name as a way to prettify the output when the Target is a particularly long string.
It must pass the output of Get-TestParam
to Invoke-PoshspecExpression
It's easiest way to do this is with splatting.
Some more information on the purpose of these functions is discussed in https://github.com/Ticketmaster/poshspec/issues/4.
Getting Started
Contributing
Functions