I wrote retrospec a while ago <https://github.com/...
# puppet
c
I wrote retrospec a while ago https://github.com/nwops/puppet-retrospec in order to retrofit modules with best practices and tests. It walked the puppet AST tree and wrote out tests for every resource along with doing things that could be templated. It was a great solution at the time but has not aged well. The PDK overlaps with this tool a few years later with the exception of retrofitting tests. I had to vendor puppet 4.x to make this work as 5.x broke everything. AI does much of these things today, but not nearly as fast and cheap as retrospec. When I was consulting this was a total game changer cause I could just type a single command. Someone beside me blogged about it a long time ago. https://www.declarativesystems.com/2016/05/03/retrofitting-testing.html Anyways, the underlying puppet parser changed and I didn't feel like rewriting things again. You can take a look at what I did and hopefully improve. Essentially though I made templates, built up a context and passed that context into the template to render out the test files. Please be aware that once you retrofit a bunch of tests to old code you now have a test maintenance problem and you may spend significant time fixing tests.