Testing Behavior of Generated Method with Dynamic Logic #76496
-
I am working on a source generator that uses an attribute to mark a type. The generator will then produce a method called:
I need to write a unit test to verify that the Sum method works correctly and returns the expected result. The focus is on testing the behavior of the Sum function, not the functionality of the source generator itself, as I have several switches that can alter the behavior of the Sum function. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Create a test library that references your generator. Then create a unit test library that references your test library. Have the unit test validate the 'sum' method that is generated into your library, just like you would write any other unit test of some piece of code. |
Beta Was this translation helpful? Give feedback.
Create a test library that references your generator. Then create a unit test library that references your test library. Have the unit test validate the 'sum' method that is generated into your library, just like you would write any other unit test of some piece of code.