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

setPostCondition stuck in infinite loop #989

Closed surecloud-malokaidi closed 4 weeks ago

surecloud-malokaidi commented 3 months ago

Describe the bug

When using setPostCondition to select a subset acceptable subclasses the generator seems to get stuck in infinite loop if the predicate evaluates to false on the class type

Your environment

Steps to reproduce

Run FixtureMonkeyTest.java from https://github.com/surecloud-malokaidi/fixture-monkey-bug

Expected behaviour

I would expect FixtureMonkey to generate a different type of class if the predicate evaluates to false

Actual behaviour

The same class type is used and only it's attributes values change each time the predicate is false resulting in an infinite number of attempts (maxing out at max tries) at creating an object satisfying the condition.

seongahjo commented 3 months ago

@surecloud-malokaidi Hello.

Sorry, currently Fixture Monkey does not support setPostCondition to filter subclasses.

The features related to subclasses are planned to be supported since 1.1.x. It would be two parts.

  1. Add new ArbitraryBuilder APIs interfaceImplements, abstractExtends (the name is same as the option in FixtureMonkeyBuilder)
  2. Extend the existing API (For example, setPostCondition) to support subclasses

In 1.0.x you should use set API to set subclasses instead.

Thank you.

seongahjo commented 1 month ago

@surecloud-malokaidi Hi, thanks for waiting. The problem is fixed in 1.0.22.

Please let me know if you experience any further problems.

Thank you very much.

seongahjo commented 4 weeks ago

The issue is closed as it has been fixed since 1.0.22. If you have any problems, please reopen the issue.