I have an app that sends some messages to the outside world, and I'd like to generate a file that has examples of these messages for the purpose of documentation. (As a secondary goal, I'd also like to validate that these messages conform to a set of specs, and fail a test if they don't.) My thought is to write a test that generates the file as a side effect, and I imagine I can get it to work with a fair bit of manual hacking but I'm wondering if there's a library or common pattern for doing this already.
I feel like I'm a little off the beaten testing path since most test runners report when a test fails, but I want to generate some output when the test succeeds as a kind of living documentation of the current behavior. This seems to fit the same niche as a test coverage file I suppose.