Skip to content

Use assertj in tests - #746

Open
ok2c wants to merge 1 commit into
apache:masterfrom
ok2c:migration_to_assertj
Open

ok2c wants to merge 1 commit into
apache:masterfrom
ok2c:migration_to_assertj

Conversation

@ok2c

@ok2c ok2c commented Nov 13, 2026

Copy link
Copy Markdown
Member

Folks, I have taken it upon myself to convert all asserts in core from JUnit to AssertJ. This has been discussed on the dev list and I hope no one has objections to using AssertJ.

@garydgregory

garydgregory commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

This is absolutely AWFUL IMO. Nasty. GROSS.

In comparison, I've purged any of this fluent nonsense with assertj and hamcrest from Commons.

@garydgregory

garydgregory commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

This is an awful way to test IMO. So much worse than plain assertions in JUnit, assertNull() is perfect. Assert that bla is Null or whatever the fluent pattern I've seen done with assertj or hamcrest is an anti-pattern for me. Hard to read and maintain. Just AWFUL!

@ok2c
ok2c force-pushed the migration_to_assertj branch from 2c7914e to 5de5a4d Compare November 13, 2026 15:35
@ok2c
ok2c force-pushed the migration_to_assertj branch from 5de5a4d to fbe1d2f Compare November 13, 2026 15:38
@ok2c

ok2c commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

@arturobernalg Do you have a preference?

@arturobernalg arturobernalg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed on the dev mailing list back in January, there was broad agreement to adopt AssertJ in core. I gave my +1 then, and I still support the change.

Thanks for taking care of this, @ok2c .

@garydgregory

garydgregory commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Have you ever tried stepping through some assertj mess in a debugger? Good luck.

@ok2c

ok2c commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

@garydgregory Out of curiosity, how often do you actually have to step through any of the HttpComponents test cases and when was the last time you had to do that?

@garydgregory

Copy link
Copy Markdown
Member

Mercifully not often but I certainly never want to deal with assertj unless I'm forced to. And it certainly will not encourage me to write new tests or update existing tests using this awful and overtly VERBOSE API that stinks of literate programming 😢

@ok2c

ok2c commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

And it certainly will not encourage me to write new tests or update existing tests using this awful and overtly VERBOSE API that stinks of literate programming

@garydgregory Not that you have done that often in the past.

I will not encourage you to write any tests, be sure of that, though one is actually welcome to continue using straight JUnit asserts for new code and new test. However given the fact that between me and @arturobernalg we write pretty much most of the tests and we actually do 100% of bug fixes, so please kindly allow us to make the choice of tools for the job.

@garydgregory

Copy link
Copy Markdown
Member

I'm not stopping you, I'm voicing my opinion. Notice I didn't say "-1'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants