geode-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kirk Lund <>
Subject [DISCUSS] Remove CatchException testing dependency
Date Thu, 23 Aug 2018 23:01:09 GMT
We have a small number of tests
using com.googlecode.catchexception.CatchException. This project isn't very
active and AssertJ provides better support for testing expected exceptions
and throwables. Most Geode developers are already using AssertJ for
expected exceptions.

I propose we update the few tests using CatchException to instead use
AssertJ and then remove our testing dependency on CatchException.

The recommended ways of handling expected exception testing would then
involve using following AssertJ APIs:

1) Basic assertion about an expected exception

Use: org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy

Example from JdbcWriterTest:

    assertThatThrownBy(() -> writer.beforeUpdate(entryEvent))

2) Complex assertion about an expected exception (potentially with many
nested causes with messages that we want to validate as well)

Use: org.assertj.core.api.Assertions.catchThrowable

Example from DeltaPropagationFailureRegressionTest:

    Throwable thrown = server1.invoke(() -> catchThrowable(() ->

        .hasMessageContaining("deserializing delta

3) Simple assertion that an invocation should not thrown (probably used in
a regression test)

Use: org.assertj.core.api.Assertions.assertThatCode

Example from RegisterInterestDistributedTest:

    assertThatCode(() ->

Let me know if you can think of another use case that isn't handled by the
above AssertJ APIs.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message