JSON-java icon indicating copy to clipboard operation
JSON-java copied to clipboard

Enhancement: Replace assetTrue with assetEquals in tests

Open Simulant87 opened this issue 1 year ago • 2 comments

There are a lot of tests with an Aaron pattern like

assertTrue("message", expected.equals(actual))

If such an fails, it only returns the message as indicator of the failure, but the difference in expected to actual value is not visible.

The assertions should be changed to:

assertEquals("message", actual, expected)

This way a failing assertion would also output the difference, which would make it easier to find the reason for it.

I would like to work on this issue and provide a PR to improve the assertions.

Simulant87 avatar Feb 22 '24 09:02 Simulant87

@Simulant87 Thanks for raising this issue. It would be better to get a 'go-ahead' before proceeding with the PR. assertEquals may be marginally better than assertTrue, and it would be reasonable to use it going forward, but I don't see a compelling reason for changing existing tests in a non-functional way.

stleary avatar Feb 25 '24 03:02 stleary

I believe it will become more relevant if and when it is decided to move forward with the JUnit 5 upgrade.

Maybe then, if possible we could correct these declarations to more conventional ones.

rikkarth avatar May 18 '24 08:05 rikkarth

Closing this issue due to recent decision to discourage changes just for the sake of refactoring. Also, there are no plans to upgrade to JUnit 5 at this time.

stleary avatar May 18 '25 16:05 stleary