3 ms·
Hi, I'm the author of hitchstory. With the stories in YAML two new use cases (which are demonstrated in the example projects) are enabled: * Automatically upd
by hitchstory 3y ago
Hi, I'm the author of hitchstory.
With the stories in YAML two new use cases (which are demonstrated in the example projects) are enabled:
* Automatically updated how-to docs. I used to write these types of docs manually and if they existed at all they would ALWAYS get out of sync with the code and were painful to maintain manually. Now I have YAML files and a simple jinja2 template I can push out new markdown how-to docs on each new build - with snippets of JSON, screenshots from the app, whatever.
* Tests that rewrite themselves. E.g. if I have a REST API test of the form "call API x and expect y blob of json", I don't have to actually write that blob of json into the test, I just write the code that produces it and run the test in rewrite mode so it updates the "expected JSON" field with actual json. I can then eyeball it and 20 seconds later it's part of the test and part of the docs.
The productivity improvements from doing both of these things means that writing tests is cheaper so I do more of them. Having how-to docs for all scenarios is way cheaper so I now always have them.
These use cases are impossible with pytest. They are impossible with cucumber.
They would be too painful to maintain with regular (i.e. not type-safe) YAML and those stories have enough indents that they would be an epic unreadable mess of syntactic noise if they were built in something like TOML or JSON.
- skrebbel 3y agoThe second thing reminds me of how Jest does snapshot testing: the first time you run it, it simply edits the JS source file with the result. For a test runner to edit test code feels weird at first but it works spectacularly well.
- dharmab 3y agoThe first thing reminds me of example tests in Go: https://go.dev/blog/examples https://go.dev/blog/examples
- hitchstory 3y agoSimilar. It's like that but in reverse. Instead of running snippets of your docs as code, the tests and their metadata are used to compile doc snippet or entire how to docs pages.
- dharmab 3y agoThat is how Go's examples work- your example tests are inlined into the GoDocs at pkg.go.dev
- fishyjoe 3y ago> Tests that rewrite themselves. That sounds like expect tests in OCaml [1]. I've found them quite a joy to work with and I'm surprised more languages don't have something similar. [1] https://dev.realworldocaml.org/testing.html#expect-tests https://dev.realworldocaml.org/testing.html#expect-tests
- Terretta 3y agoYour way of thinking, shared transparently not just in your "why not" section but throughout, is a breath of fresh air in the miasma of grabbing a tech because dogma or hype. It's not that I agree with all your choices. It's that I'll defend to the end your method of making them.