FlexTradeUKLtd / jfixture

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

Allow @Fixture to be placed on method parameters #32

Open TWiStErRob opened 7 years ago

TWiStErRob commented 7 years ago

See https://github.com/mockito/mockito/pull/444 for similar fix and linked discussion.

See motivation: https://gist.github.com/TWiStErRob/8d9abea2777c79d01513e896b3cb5ebb (Working example, I'm writing tests like this now.)

Ideally the @Fixt should be the same @Fixture annotation that's in this library.

Related: #2 is the same issue, but for JUnit 4

TWiStErRob commented 7 years ago

bump

richkeenan commented 7 years ago

Hey @TWiStErRob sorry I totally missed this! Thanks for the suggestion - I'll have a good read through those links now :)

richkeenan commented 7 years ago

There's a lot of info here from a few different places (mockito, your gist, existing issue) and I'm struggling to understand exactly what you're after as there's a mix of theory and implementation details.. Could you please write some minimal code to show (as a consumer of the library) what you'd like to achieve - then we can focus on implementation details afterwards. Thanks!

TWiStErRob commented 7 years ago

Take a look at my gist, that's the minimal example. ExampleTest (testing Example) is what I want to achieve, but I want to use the same @Fixture we use on fields, instead of the duplicated @Fixt.

This is a new (optional) way of writing tests in the next version of JUnit. It supports method parameters out of the box. The JFixtureExtension is the magic glue that could be included in this project, but that's out of scope for this issue.