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

Unable to set list value #881

Closed esfomeado closed 8 months ago

esfomeado commented 8 months ago

Describe the bug

After updating to 1.0.10 I'm now unable to set the value of lists. Sometimes is set to null other time it's set to something random and not to the value provided. This change was introduced on 1.0.10

Your environment

Steps to reproduce

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L133

Expected behaviour

I should be able to set the list value like before

Actual behaviour

The value is set to null or something random.

seongahjo commented 8 months ago

@esfomeado Is it work in 1.0.9? I had a same issue in 1.0.9. Is an option missing from the test? It is set as null because Fixture Monkey does not know the implementation of abstract class Condition. So, it can not create an implementation of Condition.

There are two solutions.

First solution

Add the interfaceImplements option. interfaceImplements(Condition.class, List.of(ValueCondition.class))

Second solution

Use setJust. set("conditions", Values.just(List.of(condition)))

I think you can go one of two ways.

esfomeado commented 8 months ago

@seongahjo Sorry you are right but I have a new bug on 1.0.10 where in some scenarios that value that is set is different from the one provided. I will try to create a replication.

esfomeado commented 8 months ago

I was finally able to reproduce the issue. You can check the same reproduction.

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L136

What happens is that Fixture Monkey generates objects again if they are of the same time.

seongahjo commented 8 months ago

@esfomeado Thank you for reproducing the issue! It is fixed in 1.0.11. Please check it out.

esfomeado commented 8 months ago

Fixed. Thanks