首页 > 解决方案 > Is there a way I can create an either OR assertion using Pester test framework?

问题描述

For example if I wanted to assert the value should be Value1 or Value2 (either is acceptable):

   It 'Value must match Value1 or Value2' {
         $params.value | Should -be "Value1" || "Value2"
    }`

This is invalid syntax - is there a way to do this with Pester?

标签: powershellunit-testingtestingassertionpester

解决方案


你想要-BeIn断言

if 'Value must match Value1 or Value 2' {
    $params.Value |Should -BeIn @('Value1','Value2')
}

推荐阅读