j256 / ormlite-core

Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android
http://ormlite.com/
ISC License
578 stars 213 forks source link

Fix flaky testCanBeNull in FieldTypeTest.java #228

Closed NanaOkada closed 3 years ago

NanaOkada commented 3 years ago

Fixed the flakiness in the test com.j256.ormlite.field.FieldTypeTest.testCanBeNull. It was flaky because the order of fields the method getDeclaredFields() returns is nondeterministic. I sort the Fields[] after I get them, so the field that can be null will always be the second one in the Field[], and the field which can't be null will be the first one. Then I get the name field by using Field field = fields[1];, Field field = fields[0]; respectively.

j256 commented 3 years ago

Fixed this better with ced03ce49dc392529922a059de592ede074c2925. Thanks @NanaOkada .