In general, when I'm writing tests, the pure functions end up as bare expects and the impure functions end up as scenarios. The following contrived namespace keeps a list of users and allows you to get the full name of each user.
The tests for this namespace would often look something like the following code:
It feels natural to put the with-redefs in a scenario, since scenarios also support (and often make use of) stubbing, localize-state, & freeze-time. However, there's really no reason that you need to use a scenario if you're simply looking to redef a var.
The following test provides the same level of functionality verification, without needing to use expectations.scenarios:
scenarios are great, but these days I try to keep things simple with bare expectations whenever possible.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.