trino: Change tests not to use "fail() + catch" pattern
Some tests use the following pattern
try {
... do something ...
fail();
}
catch (IllegalStateException e) {
assertEquals(e.getMessage(), "the expected message");
}
this is not very readable and can be expressed more tersely with assertThatThrownBy
also, in case the message not as expected, the actual failure gets lots, so it’s harder to diagnose the problem
find all occurrences of such pattern and migrate to assertThatThrownBy
see https://github.com/trinodb/trino/pull/6554 for example of such migration
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (13 by maintainers)
@findepi Here are the remaining “fail() + catch” pattern.
trino-blackhole
trino-hive
AbstractTestHive
TestFSDataInputStreamTail
TestHiveTypeTranslator
trino-main
FunctionAssertions (used inside a deprecated method)
TestClientBuffer
trino-phoenix5
trino-product-tests
trino-prometheus
- trino-spi- TestUnscaledDecimal128Arithmetic~~- https://github.com/trinodb/trino/blob/master/core/trino-spi/src/test/java/io/trino/spi/type/TestUnscaledDecimal128Arithmetic.java#L631-L644~~@findepi yes, I would like to help with review
I think there are legitimate cases where verifying some condition.
We shouldn’t need to
as
reads better.
Of course, we could use
throw new AssertionErrorin these cases, but we should make sure we have an agreement on this first.