Skip to content

GH-3615: Replace @Test(expected=...) with assertThatThrownBy() checks#3636

Open
nastra wants to merge 1 commit into
apache:masterfrom
nastra:better-exception-testing
Open

GH-3615: Replace @Test(expected=...) with assertThatThrownBy() checks#3636
nastra wants to merge 1 commit 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

@nastra nastra force-pushed the better-exception-testing branch from 416c14c to cbf5d49 Compare July 3, 2026 12:14
@nastra nastra force-pushed the better-exception-testing branch from cbf5d49 to 94a3b14 Compare July 3, 2026 12:16
@nastra nastra changed the title Replace @Test(expected=...) with assertThatThrownBy() checks GH-3615: Replace @Test(expected=...) with assertThatThrownBy() checks Jul 3, 2026
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.

2 participants