Open LPeter1997 opened 3 years ago
I use following approach. https://github.com/kant2002/WinFormsComInterop/blob/0b2edf8bb8c6f1a1586f63f1d4b8ac18ab21bf45/WinFormsComInterop.SourceGenerator.Tests/CodeGenerationTestBase.cs#L13
Maybe your specific way how to test would be different. For example you can consider creation of small application which declare parsers with specific features, then these application would run and validated to be producing desired outputs.
@kant2002 Generating the output as a string and comparing it is definitely one way, thanks for showing it to me! I'll have to consider if this is the best approach.
I'm planning to move away my generation logic to use Scriban templates, so maybe involving the compiler won't even be necessary.
Generator projects are something we definitely should test as they are key parts of the libraries.