You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This test fails and the person instance is generated with a negative age, which is not intended by the class designer.
As a class designer, if I want to enforce some rules while setting fields to make sure my object's internal state is valid, I do not want Easy Random or any other library to bypass my setter and create invalid instances of my class, unless I explicitly tell the library to do so (with an option like bypassSetters, see #398 ).
If one wants the library to generate valid values without bypassing setters, one can register a custom randomizer for the target field. For the previous example, it could be:
As of v4.2, Easy Random does not fail when a setter invocation fails. Here is a quick example with a failing test:
This test fails and the person instance is generated with a negative age, which is not intended by the class designer.
As a class designer, if I want to enforce some rules while setting fields to make sure my object's internal state is valid, I do not want Easy Random or any other library to bypass my setter and create invalid instances of my class, unless I explicitly tell the library to do so (with an option like
bypassSetters
, see #398 ).If one wants the library to generate valid values without bypassing setters, one can register a custom randomizer for the target field. For the previous example, it could be:
The text was updated successfully, but these errors were encountered: