With this sort of case
LogAssert expect = TestLoggers.sys().expect("org.spf4j.test", Level.WARN,
LogMatchers.hasFormat("Booo"));
LOG.warn("Booo", new RuntimeException());
// oops, lost the `assertObservation`!
the test will not fail if it does not produce the expected logs.
The @ExpectLog annotation avoids this hazard, but it is limited by the annotation requirement of only using compile-time values.
It'd be nice to have ways that make sure the assertion always runs and that still let you use matchers.
(Exactly how that looks probably depends on the test framework.)
With this sort of case
the test will not fail if it does not produce the expected logs.
The
@ExpectLogannotation avoids this hazard, but it is limited by the annotation requirement of only using compile-time values.It'd be nice to have ways that make sure the assertion always runs and that still let you use matchers.
(Exactly how that looks probably depends on the test framework.)