Replies: 2 comments 4 replies
-
I dont understand the point in using the generic attribute. I use a custom version of the AutoDataAttribute now for years basically doing the same. The problem with generics is that you cannot have something like params. So if you want to use more than one IFixtureConfigurator, you have to add additional versions of the type. So your implementation looks like this
while I use
The advantage of the seperate attribute is that you can easily go one step further. These attributes I allow to be put not only on methods, but also on classes and assemblies. |
Beta Was this translation helpful? Give feedback.
-
As said I have re-written some of the basic AutoFixture xUnit classes to fullfill this demand. I use my own version of the AutoDataAttribute as a starting point.
As you can see it is basically a copy of the original AutoDataAttribute from AutoFixture.xUnit adding this handling of the customization attributes. All other attributes are just passing the xUnit attribute on to this class. So I have MemberAutoDataAttribute, InlineAutoMemberAttribute and ClassAutoDataAttribute. Last but not least I have plain AutoDataAttribute passing on some NullDataAttribute. From there on you can subclass further weith MemberAutoNSubstituteAutoDataAttribute, InlineAutoNSubstituteDataAttribute and so on. Hope you get the idea. Going deeper a discussion is probably the wrong place. If you are interested I can share the full code. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I just published a blog post where I describe a technique that aims at easing the pain of using the AutoData flow with multiple setups of the same type.
https://renatogolia.com/2023/11/29/leveraging-generic-attributes-test-specific-customizations-autofixture/
Beta Was this translation helpful? Give feedback.
All reactions