有没有办法用DSL风格检查Kotest中的多个断言--不使用JUnit的Assertions.assertAll方法?
我可以写这样的东西吗?
firstValue shouldBe 1
and secondValue shouldBe 2而不是
assertAll(
{ fistValue shouldBe 1 },
{ secondValue shouldBe 2 })发布于 2020-07-14 01:14:50
我通常和assertSoftly一起做。这可能正是您想要的。从documentation
assertSoftly {
foo shouldBe bar
foo should contain(baz)
}或将其用作参数
assertSoftly(foo) {
shouldNotEndWith("b")
length shouldBe 3
}但是,您的语法也可以正常工作。你真的不需要轻声断言。
firstValue shouldBe 1
secondValue shouldBe 2将执行这两个断言。如果第一个测试失败,那么测试就会提前崩溃。对于assertSoftly,这两个断言都将被检查。
https://stackoverflow.com/questions/62880294
复制相似问题