Comment by quickthrower2
3 years ago
Reminds me of approval tests. Which I think are a wonderful idea. https://approvaltests.com/
Humans are better at verifying the answer is correct over coming up with the answer.
The thing that makes test writing unjoyous for me is most code is hard to test, usually requiring all kinds of scaffolding and even resources like files, db, or mocked http requests.
Being Jane Street they probably use OCaml so yes functional programming languages are nicer to write tests in.
Ah neat, I've heard different names for snapshot/golden master type testing before, but generally find the tooling a bit lacking. It seems like https://github.com/approvals/ actually has pretty decent implementations for most languages.
I feel like the Jane Street approach of embedding the snapshots directly in test sources would make a qualitative difference to the ergonomics. The post implies that this requires some emacs integration, but there's no reason it couldn't be done by a test runner process instead. It would also be cool to have an LSP that provide a hover text or go-to-definition for externally stored snapshots.
> usually requiring all kinds of scaffolding and even resources like files, db, or mocked http requests
Yes, anything with timestamps or generated identifiers gets very annoying as you have to manually exclude certain data from the snapshots, negating some of the "easy wins" a snapshot/approval process provides for pure/idempotent code.
A VSCode plugin could inline the expected answer file, or at least link to it. I like a seperate file because what if you want whitespace checkin behaviour to be different?