What’s the difference between ScalaTest and Scala Specs unit test frameworks?

前端 未结 5 1747
耶瑟儿~
耶瑟儿~ 2021-01-29 19:49

Both are BDD (Behavior Driven Development) capable unit test frameworks for Scala written in Scala. And Specs is built upon may also involve the ScalaTest frame

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-29 19:51

    The main differences are (mostly from a specs point of view :-) ):

    • ScalaTest provides more "testing styles" than specs (you can visit each bullet point on the quick start page to get a detailed view on each style)

    • ScalaTest and specs have a different set of matchers. You can compare them here for ScalaTest and here for specs. On that side of things, specs has a lot of small features that you may like when writing your specification: xml matchers, matchers composition (an easy way to reuse matchers by transforming them), precise failures, detailed differences for long strings, ...

    • Mockito has been given a nice BDD support in specs: Mockito

    • specs has DataTables which allow to group a lot of small example in a sort of table (if you can stand operators being used as the table delimiters)

    • In specs, you can define examples which are nested as libidum and automatically cleaned-up at every level

    This is certainly a very partial and biased comparison and many other differences exist (and the libraries are still evolving, ...).

    At the end of the day I think that it really depends on your testing/specifying style. If it's simple (simple specification structure, setups, expectations, ...) then both libraries will appear very similar. Otherwise, both have their take on how things should be done. As a last example of this you can have a look at tagging: in ScalaTest and in specs.

    I hope this helps.

提交回复
热议问题