Starting from Pester 5.1 you can use New-PesterContainer -Data @{}
to pass all required parameters to Invoke-Pester
.
You can pass now path to both a single test file or a test directory to Invoke-Pester -Path
.
For instance, you have a test file:
param($param1, $param2)
Describe '' {
It '' {
$param1 | Should -Be '...'
$param2 | Should -Be '...'
}
}
Then you run it like this:
$container = New-PesterContainer -Path <tests_directory> -Data @{ param1='...'; param2='...' }
Invoke-Pester -Container $container
The official documentation is here: https://pester.dev/docs/usage/data-driven-tests#providing-external-data-to-tests
The list of new features you can find here: https://github.com/pester/Pester/releases/tag/5.1.0