GeistHaus
log in · sign up

goldentest

pkg.go.dev

Package goldentest makes it easy to build tests that compare outputs (got) that come from a system under test (SUT) against version control-managed reference files (want) and facilitate the management of the reference files (want) as SUT behavior changes.

1 page links to this URL
Golden File Testing

Today, driven by annoyance, I refactor-extracted a small set of test helper code found in various private personal projects around the topic of golden file management into a dedicated Go module: github.com/matttproud/goldentest (API documentation). I’m happy to finally have a canonical solution that I am happy with. I’ll freely admit it: I use change detector tests1 for some things, as a slew of these personal projects use reference data defined in the testdata directory as canonical want values that got is compared against. It’s practical: for code that generates HTML files, I can inspect the files in a browser or local web server and verify behavior conformance. Same goes for end-to-end tests that generate output. In select cases, it is easier than redefining onerous data literals in my test themselves — not that I like indirection all that much.

0 inbound links article en posts GoSweTesting