naver / fixture-monkey

Let Fixture Monkey generate test instances including edge cases automatically
https://naver.github.io/fixture-monkey
Apache License 2.0
560 stars 89 forks source link

Make the API to use a javaGetter neater #849

Open esfomeado opened 9 months ago

esfomeado commented 9 months ago

Describe the feature you request

As of now in Java you can use getters to set a value as specified on the documentation.

    Order actual = sut.giveMeBuilder(Order.class)
            .set(javaGetter(Order::getOrderNo), "1")
            .set(javaGetter(Order::getProductName), "Line Sally")
            .minSize(javaGetter(Order::getItems), 1)
            .sample();

I think that it´s to verbose and not as neat as Kotlin where you can just do .setExp(Order::orderNo, "1").

I suggest to be a similar syntax as well for Java users.

seongahjo commented 9 months ago

@esfomeado Thanks for the suggestion. Do you have any good ideas?

Do you want an API that looks like this?

Order actual = sut.giveMeBuilder(Order.class)
    .setExpGetter(Order::getOrderNo, 1)
    .sample();
esfomeado commented 9 months ago

That looks good to me.