Access to fixture created by AutoData attribute.
See original GitHub issueHi, For now i only can access the fixture like this.
[Theory, AutoData]
public void Dummy(string dummy)
{
MethodBase method = MethodBase.GetCurrentMethod();
IFixture fixture = method.GetCustomAttribute<AutoDataAttribute>().Fixture;
Assert.Equal(dummy, dummy);
}
And I get the ‘AutoDataAttribute.Fixture’ is obsolete warning.
Is there a better way to access the fixture created in the AutoData attribute. I would like to mix parameter and manual creation and injection. Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to create Mock classes in AutoDataAttribute ...
I want to inject the mock classes in the fixture, I only got one answer that helps me fix the base class warning...
Read more >Autofixture Generate Specific Format Values By Extending ...
Extend AutoDataAttribute. To allow for our requirement to be met we need access to the Fixture instance which is being used to generate...
Read more >Test Data Generation With AutoFixture in .NET
AutoFixture is a powerful library for test data generation in .NET projects. Its main goal is to automate the process of creating test...
Read more >Why I stopped worrying about test setups by using ...
We're going to continue to use the XUnit's parameterized tests, and create an AutoDataAttribute to provide the parameters to the test.
Read more >xUnit Autodata with autofixure
Autofixure => provides anonymous test data (data that is required to execute test, but the value itself is Unimportant) · Autofixure can also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, it’s really a better way.
Can you put this in the AutoData wiki? I have searched everywhere to find how to do this. Did not think the IOC container got the IFixture registered.
Thanks a lot!
Hi,
Sure, simply ask underlying fixture to resolve
IFixture
instance and it will return self:Does it work for you? 😉