FlexTradeUKLtd / jfixture

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

Create FixtureResolver #60

Closed veluxer62 closed 1 year ago

veluxer62 commented 4 years ago

The FixtureResolver functions to generate function parameter data for test.

I referred here:

veluxer62 commented 4 years ago

When I add Map and List type parameter, There are empty value in the test parameter data. Is there any problems in my code?

TWiStErRob commented 4 years ago

I had similar problems when I wrote a Kotlin extension function. I had to use fixture.collections() to create them. Not sure why though.

veluxer62 commented 4 years ago

@TWiStErRob When worte Map and List type variable in class. fixture generated data as I expected. See 22 to 31 lines in FixtureResolverTest.java .

TWiStErRob commented 4 years ago

Yeah, the difference is having it as part of another Class (field, ctor param); that works fine, but directly fixture.create(new SpecimenType<List<String>>() {}) doesn't work.

rses commented 4 years ago

I've had the same issue with collections - ended up using Kotlin generator functions, didn't look much into it and chalked it up to type erasure.

While this is a good added feature (parameterised @Fixture), I'm just wondering why not just use member variables with @Fixture? Is it for readability? (genuinely asking, not being a troll :) )

TWiStErRob commented 4 years ago

@rses it's just how JUnit 5 works. In most test classes individual tests don't use all of the fixtures, and also they also create more in local variables. There's a reason while injected parameters become a thing in JUnit 5.

Do you mean operator invoke by "generator"?