FlexTradeUKLtd / jfixture

JFixture is an open source library based on the popular .NET library, AutoFixture
MIT License
105 stars 22 forks source link

FluentCustomisation doesn't work nicely with FixtureRule #20

Closed phutchin closed 9 years ago

phutchin commented 9 years ago

If using annotated fixtures, then they can be initialized by adding this to the test: @Rule public FixtureRule fr = FixtureRule.initFixtures(new JFixture())

but if I want to customise the fixture, I need to setup the customisations in a constructor, and it makes the tests a bit messy.

phutchin commented 9 years ago

One suggestion for a fix would be to add a method to FluentCustomisation which returns JFixture, allowing you to do: @Rule public FixtureRule fr = FixtureRule.initFixtures(new JFixture().customise().sameInstance(MyClass.class, myInstance).jfixture());

phutchin commented 9 years ago

After a bit more of a think. I think it might be nicer to do

@Rule public FixtureRule fr = FixtureRule.initFixtures().customise().sameInstance(MyClass.class, myInstance)