【问题标题】:How do I test "should not contain" using FsUnit.Xunit?如何使用 FsUnit.Xunit 测试“不应包含”?
【发布时间】:2020-11-18 03:37:36
【问题描述】:

我正在尝试使用FsUnit.Xunit 测试集合是否不包含值。

open FsUnit.Xunit

[<Fact>]
let ``simple test`` () =
  let xs = [ 1; 2; 3 ]

  xs |> should contain 1

  xs |> should not contain 99 // Not real code

我也尝试过使用not'。

我该怎么写?

【问题讨论】:

    标签: f# xunit fsunit


    【解决方案1】:

    你只需要把它用括号括起来,因为它需要一个约束(而不是一个函数)。 contain 是一个函数,它需要一个值并返回一个约束。

     xs |> should not' (contain 99) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-11
      • 2014-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-30
      • 1970-01-01
      • 2011-11-16
      相关资源
      最近更新 更多