openpojo icon indicating copy to clipboard operation
openpojo copied to clipboard

Sort fields in PojoFieldFactory for deterministic order

Open hsiangawang opened this issue 3 years ago • 1 comments

The test BusinessIdentityTest.testToString compares the result with a hardcoded string. However, the function BusinessIdentity.toString did not return the deterministic string. From code trace, the root cause is the method PojoFieldFactory.getPojoFields, which calls on Java's reflection api getDeclaredFields. There is no guarantee in order of the returned fields and thus, some tests can fail due to a different order:

  • BusinessIdentityTest.testToString

  • BusinessIdentityTest.testGetHashCode

This PR proposes to sort the returned fields and make it deterministic.

hsiangawang avatar Nov 28 '20 20:11 hsiangawang

Pull Request Test Coverage Report for Build 307

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 96.418%

Totals Coverage Status
Change from base Build 306: 0.003%
Covered Lines: 3149
Relevant Lines: 3266

💛 - Coveralls

coveralls avatar Nov 28 '20 20:11 coveralls