A testing library that turns your README into executable tests ↦
This is a very cool idea coming out of the Clojure community. I dig it because the examples in your README are guaranteed to never become stale as your project evolves.
It works by parsing your README and looking for executable code samples with expected outputs. For each one it finds, it generates a test ensuring that executing the code produces the output.
There are, as you might expect, caveats.
Discussion
Sign in or Join to comment or subscribe
Anders Hovmöller
2020-03-04T16:59:47Z ago
Yea. Not very new: https://github.com/boxed/midje-readme
Anders Hovmöller
2020-03-04T17:00:25Z ago
I habe you covered for python too https://github.com/boxed/pytest-readme
Jerod Santo
Bennington, Nebraska
Jerod co-hosts The Changelog, crashes JS Party & takes out the trash (his old code) once in awhile.
2020-03-04T19:00:54Z ago
The concept was new to me! Very cool stuff, thanks for sharing.
Sean Corfield
2020-03-08T17:39:24Z ago
Yes, I’ve used midje-readme for years on several projects but I wanted something that was a) simpler with fewer dependencies and b) supported the more common user=> REPL session format I see in a lot of README files.
Anders Hovmöller
2020-03-09T04:44:40Z ago
Ah. Nice about the format.
I guess midje-readme could isolate out the single dependency on Watchtower to a sub feature for the live case. Oh well, I don’t do any Clojure anymore :) But if someone submits a PR I’ll give commit rights.
Sean Corfield
2020-03-09T05:15:40Z ago
The dependency I wanted to avoid was Midje itself! That drags in a ton of other things. I know projects that were using midje-readme but were not otherwise using Midje for testing so this is targeting those (such as HoneySQL, which I maintain these days).
Anders Hovmöller
2020-03-09T05:23:57Z ago
Oh. In my day midje was the thing everyone used. I guess that’s no longer the case! Thanks for clarifying this.
I’m happy to see you make the effort to have the line numbers In the tests align with the readme. This was, I believe, my original idea.