In Scalatest, I'm a bit unclear as to the advantages and disadvantages of using Spec versus WordSpec. I think the javadoc provide some degree of comparison of WordSpec versus FlatSpec, but I have no idea between Spec and WordSpec.
Which would be considered "best practice" if you are comfortable with either syntax?
Is WordSpec an evolution of Spec (if one subscribes to the notion that BDD is an evolution over TDD)? Or vice versa? If they are completely equal peers in that regard, why would I pick one over the other?
Perhaps this is a "religious question" but even if it is those that are on each side must at least have some pluses and minuses they like to point out. I'd be very interested in hearing those arguments.
If this is a FAQ, I apologize in advance: I could not find anything in my searches on this comparison.
The main premise behind the FlatSpec trait is to help facilitate a BDD style of development. It's named flat because the structure of the tests we write is unnested in nature. In addition, this trait tries to guide us into writing more focused tests with descriptive, specification-style names.
Spec has no implicit conversions other than the default one you get with Suite, which puts === on everything. WordSpec has a few implicit conversions to put words after strings, so it has slightly more risk for implicit conversion conflict.
Spec allows indefinite nesting. WordSpec only provides 3 levels of nesting.
Spec gives you more freedom on how you structure the text of your specification (though not as much freedom as FreeSpec). WordSpec is quite prescriptive on how you'll structure your text.
WordSpec is more DSLish than Spec. Some people prefer that.
If people don't have a preference I point them to Spec as the default choice, because it has fewer implicits by default, more freedom, less DSL, and more nesting, but primarily this choice is a matter of taste.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With