6 ms·
> The testing frameworks out there are still fairly spartan from the developer experience standpoint. At IMVU, we built up a bit of scaffolding along these lin
by implicit 11y ago
> The testing frameworks out there are still fairly spartan from the developer experience standpoint.
At IMVU, we built up a bit of scaffolding along these lines: https://gist.github.com/andyfriesen/43d886ce60927c69b3d1 https://gist.github.com/andyfriesen/43d886ce60927c69b3d1
The basic premise is that all our business actions can either be run "for real" through Yesod, or within a State-based framework that's part of our standard testing scaffold.
The end result is that it's trivial to write tests that arrange for the database, clock, sockets, and so forth to be in precisely the state we want them to be for the test, and to sense everything afterward.
Running these tests as pure State actions has additional benefits:
Since State operates by making successive state copies for each "mutation", test fixtures are easily effected by performing some actions and saving the produced state. Individual tests can start from this state as many times as desired. The state is immutable, so test interference is impossible.
Additionally, tests run without access to IO. This means that the compiler rejects any test which could forseeably intermittently fail.
- akurilin 11y agoGreat, I'll need to mine that for ideas, thanks for sharing! Are IMVU web-services also Yesod-based?
- implicit 11y agoThey are for now, but we've been whittling away at it. We don't actually use any of Yesod's affordances except for its router. We're aiming to eventually split that off and run on bare Warp.
- akurilin 11y agoAny particular reason why Yesod isn't a good fit there? Is the team large enough where it makes more sense for you to roll your own and not deal with making it super generic?
- implicit 11y agoYesod provides a ton of functionality related to the larger problem of building a website with Haskell, but we're only using Haskell for JSON services. All those extra bells and whistles are wasted on us. :)
- axman6 11y agoSounds like you need servant, i've found writing pretty minimal web services in it really nice.
- platz 11y agoor Airship https://blog.helium.com/helium/2015/04/01/helium-webmachine-airship.html https://blog.helium.com/helium/2015/04/01/helium-webmachine-... which uses the webmachine model. Very nice for for APIs.