【发布时间】:2021-08-16 15:51:40
【问题描述】:
如果我这样做,请使用 Specs2:
1 must beEqualTo(2)
1 must beEqualTo(1)
测试失败(如预期)
如果我这样做:
Result.foreach(1 to 10) { i =>
i must_== 2
}
Result.foreach(1 to 10) { i =>
i must_== i
}
测试通过
对于Result.foreach,我必须使用and 使测试失败(如预期的那样):
Result.foreach(1 to 10) { i =>
i must_== 2
} and
Result.foreach(1 to 10) { i =>
i must_== i
}
这是为什么?
有没有办法让它以一种不那么令人惊讶的方式工作?这很容易出错 - 很容易不注意到有人没有输入and
我检查了Specs2 user guide,但没有提到我能找到的这种行为。
【问题讨论】:
标签: scala unit-testing collections specs2