Skip to content

Migrate ExpectedException to assertThrows#56

Merged
nlativy merged 2 commits into
masterfrom
migrate-to-assertthrows
Apr 27, 2026
Merged

Migrate ExpectedException to assertThrows#56
nlativy merged 2 commits into
masterfrom
migrate-to-assertthrows

Conversation

@nlativy
Copy link
Copy Markdown
Collaborator

@nlativy nlativy commented Apr 27, 2026

Summary

  • ExpectedException has been deprecated since JUnit 4.13 in favor of assertThrows, which scopes the expectation to a specific call rather than the whole test method.
  • Convert all uses across AcaiTest, DependenciesTest, TestScopeTest, and TestingServiceManagerTest. Also convert two equivalent try/catch+fail() blocks in AcaiTest.
  • Where relevant, hoist non-throwing setup (e.g. Acai.apply(...) returning a Statement) out of the assertThrows lambda to satisfy Error Prone's AssertThrowsMinimizer.

Test plan

  • mvn clean test — all 43 tests pass

nlativy added 2 commits April 27, 2026 21:15
ExpectedException has been deprecated since JUnit 4.13 in favor of
assertThrows, which scopes the expectation to a specific call rather
than the whole test method. Convert all uses across the test suite
plus two equivalent try/catch+fail() blocks in AcaiTest. Where
relevant, hoist non-throwing setup out of the assertThrows lambda to
satisfy Error Prone's AssertThrowsMinimizer.
The only direct hamcrest reference was the isA matcher in
TestingServiceManagerTest, which went away with the assertThrows
migration. JUnit 4 still pulls in hamcrest-core transitively, so the
explicit org.hamcrest:hamcrest:3.0 dep is no longer earning its
keep.
@nlativy nlativy force-pushed the migrate-to-assertthrows branch from 4cfb643 to c2703f7 Compare April 27, 2026 20:16
@nlativy nlativy merged commit cba7664 into master Apr 27, 2026
3 checks passed
@nlativy nlativy deleted the migrate-to-assertthrows branch April 27, 2026 20:23
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