4 ms·
A related Elixir feature you might also find interesting is Doctests: https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html https://elixir-la
by mcintyre1994 3y ago
A related Elixir feature you might also find interesting is Doctests: https://elixir-lang.org/getting-started/mix-otp/docs-tests-and-with.html https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...
You can write inline examples in your docstrings and they’re automatically turned into unit tests. So again you get that documentation as an executable test suite not subject to rot, but at a per-function level. Same kind of idea but different levels of the documentation stack.
- mfwgenerics 3y agoThis is neat! Cheers
- troupo 3y agoI still don't understand why more languages don't have doc tests.
- mcintyre1994 3y agoI think there's two main things: - Elixir's scripting makes it super easy to write a one-liner that tests a function, that'd be a lot more verbose in many other languages - You need the docs tool and unit tests tools to 'speak the same language' to make it work, and for whatever reason Elixir devs don't seem as intent on reinventing tools like those as some other languages