I like the txtar file format mentioned in this video. (Described below.) I’ve worked with teams who would have rejected this idea from a junior dev because it might sound too simple. It’s easy to forget the inherent value of simplicity, which is at odds with impressive-sounding features, or demonstrating hard-won coding sophistication.
This is the complete txtar file format: One or more comment lines followed by zero or more virtual files. Each virtual file begins with a line like “-- filename --“ and ends at the next such line. Specifically, these filename lines are those beginning with dash dash space and ending with space dash dash. That’s the whole format.
It avoids the need to have multiple real files all over the place when you want just one real file but you want your code to think in terms of multiple files. (Eg have one txtar file that combines different blocks of test data.)
chezmoi (<https://chezmoi.io> or <https://github.com/twpayne/chezmoi>) has a couple dozen txtar tests. They are both amazing and completely frustrating to use, but I don't think that there would be a better way to test most of what chezmoi does without them.
Tom Payne (the creator and primary developer of chezmoi) has added some extra commands to the txtar context which makes things easier for certain classes of testing.
This is the complete txtar file format: One or more comment lines followed by zero or more virtual files. Each virtual file begins with a line like “-- filename --“ and ends at the next such line. Specifically, these filename lines are those beginning with dash dash space and ending with space dash dash. That’s the whole format.
It avoids the need to have multiple real files all over the place when you want just one real file but you want your code to think in terms of multiple files. (Eg have one txtar file that combines different blocks of test data.)