-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
I recently introduced PreconditionAssertions
to simplify tests which assert that a PreconditionViolationException
was thrown; however, I haven't found the time to make sure we consistently use PreconditionAssertions
.
We still have around 350 uses of PreconditionViolationException.class
in the code base, and most of those are assertions that could be replaced with PreconditionAssertions
.
For example, tests like this:
@Test
void exceptionWithoutAnyFilters() {
var actual = assertThrows(PreconditionViolationException.class, () -> new OrFilter(Set.of()));
assertEquals("filters must not be empty", actual.getMessage());
}
... can be replaced with:
@Test
void exceptionWithoutAnyFilters() {
assertPreconditionViolationFor(() -> new OrFilter(Set.of())).withMessage("filters must not be empty");
}
However, since we intend to backport several things from main
to 5.x in the near future, we should hold off on refactoring our test suite until the backports have been completed. Consequently, I have tentatively assigned this task to the 6.0.0 milestone.