Skip to content

Replace @Test(expected=...) with assertThatThrownBy() checks#3636

Open
nastra wants to merge 2 commits into
apache:masterfrom
nastra:better-exception-testing
Open

Replace @Test(expected=...) with assertThatThrownBy() checks#3636
nastra wants to merge 2 commits into
apache:masterfrom
nastra:better-exception-testing

Conversation

@nastra

@nastra nastra commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Replaced the old @Test(expected = SomeException.class) patterns in the tests with assertThatThrownBy(...), asserting on both the exception type and the message

The reason for the change is because @Test(expected = SomeException.class) can't assert on the exception message at all. Also, it's not clear which statement in the entire test method threw the exception, so a test could pass for the wrong reason

What changes are included in this PR?

Are these changes tested?

yes, existing tests

Are there any user-facing changes?

no

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.

1 participant