【问题标题】:Is there a way I can create an either OR assertion using Pester test framework?有没有一种方法可以使用 Pester 测试框架创建一个 OR 断言?
【发布时间】:2021-05-12 06:36:22
【问题描述】:

例如,如果我想断言值应该是 Value1 或 Value2(任何一个都可以接受):

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

这是无效的语法 - 有没有办法用 Pester 做到这一点?

【问题讨论】:

    标签: powershell unit-testing testing assertion pester


    【解决方案1】:

    你想要-BeIn assertion:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-04
      • 2022-12-07
      • 1970-01-01
      相关资源
      最近更新 更多