pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.08k stars 470 forks source link

Throw when providing null or empty array to -ForEach #2537

Closed fflaten closed 2 months ago

fflaten commented 2 months ago

PR Summary

Throw during Discovery when Describe/Context/It is provided $null or @() to -ForEach/TestCases to avoid silent failure.

The previous behavior, ignoring the test/block, can be achieved by setting the configuration option Run.FailOnNullOrEmptyForEach to $false.

When enabled, individual blocks or tests can be overriden to allow empty array or null by adding a new -AllowNullOrEmptyForEach parameter to Describe/Context/It, e.g. if a test is generated using external data which might be empty.

Fix #2151

PR Checklist

fflaten commented 2 months ago

/azp run

azure-pipelines[bot] commented 2 months ago
Azure Pipelines successfully started running 1 pipeline(s).
fflaten commented 2 months ago

/azp run

azure-pipelines[bot] commented 2 months ago
Azure Pipelines successfully started running 1 pipeline(s).
fflaten commented 2 months ago

@nohwnd It already paid off 😄 https://github.com/pester/Pester/pull/2537/commits/a365340907ef8b87a42b11c8457185ce0e61cb05

fflaten commented 2 months ago

/azp run

azure-pipelines[bot] commented 2 months ago
Azure Pipelines successfully started running 1 pipeline(s).
nohwnd commented 2 months ago

Amazing work!