Handling Doubles in ScalaTest

前端 未结 2 788
旧时难觅i
旧时难觅i 2020-12-18 22:59

I have just started using ScalaTest and I am using the following to compare two Doubles in my spec as follows:

  it should \"calculate the price\" in {
    v         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-18 23:22

    You can simply do actual shouldBe (expected +- tolerance) if using FlatSpec; other specs have similar matchers instead of shouldBe. It gives better messages in case of failures than assert, and the code is consistent with the other tests.

提交回复
热议问题