blog-examples icon indicating copy to clipboard operation
blog-examples copied to clipboard

Testing additional files in Incremental source generator snapshot tests

Open tm-nti opened this issue 1 year ago • 1 comments

I have read your awesome article on testing incremental generators: https://andrewlock.net/creating-a-source-generator-part-2-testing-an-incremental-generator-with-snapshot-testing/

Which is great for testing compiled code, but in my use case I have some .json files I want to base the generated code on. I am using the procedure described in the cookbook. I managed to modify the testutil class (gist) and it seems to work

I mostly wish to know if there is a better way to do this, my modification feels dodgy and I am no expert on source generators

tm-nti avatar Sep 24 '24 11:09 tm-nti

Thanks @tm-nti, I've implemented own source generator unit tests using your code example.

Result described here: https://gist.github.com/sergey-shambir/fb32a3011d8049b1b9ee76ed417ccc89

sergey-shambir avatar Dec 20 '24 12:12 sergey-shambir