Hi all, I've written up a macro that provides some fix-its to the user when they try to apply my macro to a struct
or enum
instead of a class
. I would like to write unit tests that validate the fixed code generated by my fix-it. So far I haven't found anything on the forums or elsewhere on the internet suggesting this is possible. Does anyone here know differently?
I've only begun to explore writing tests for macros myself but I think this library will help make your testing easier. GitHub - pointfreeco/swift-macro-testing: Magical testing tools for Swift macros.
Hi!
For unit testing macros, I recommend exploring SwiftSyntax's macro examples. They provide valuable insights. Specifically, check out AddBlockerTests.swift for an example of unit tests involving fix-its. This should help you with your tests.
Best of luck!