You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In other words, we let debug() and trace() calls pass through to an underlying Logback implementation to ensure that this output can be seen when running tests. warn() and error() logging will cause assertion failures. (The same will go for info() calls because we set up our mocks to always fail on non-mocked methods).
However... moving all of this to use slf4j-mock is a bit of work, since we currently construct our mock/test objects in a @BeforeEach-method with JUnit. I'd really prefer an "imperative" approach where I manually construct the object being tested. This is part of what the @BeforeEach-method looks like at the moment:
One of the main motivations for looking at slf4j-mock is to get rid of this ugly manual logger injection here in the TimescaleDBEventPopulator constructor call. It would be really nice to just let slf4j-mock provide the SLF4J implementation to the class, so that we could remove this constructor parameter altogether, but preferably without having to move our whole setup to use a @Mock / @InjectMocks-based approach.
Sorry if what I'm trying to convey here might be a bit fuzzy. I think what I'm aiming for is mostly to minimize the impact on our existing test setup etc, if possible.
The text was updated successfully, but these errors were encountered:
Thanks, that could be an approach worth considering yes. 👍 How well would this work with tests executing in parallel though? (we use a setup like this)
Thanks, that could be an approach worth considering yes. 👍 How well would this work with tests executing in parallel though? (we use a setup like this)
Hi,
I discovered your project today when thinking about better ways to handle logging-based testing. Our current setup is roughly like this:
In other words, we let
debug()
andtrace()
calls pass through to an underlying Logback implementation to ensure that this output can be seen when running tests.warn()
anderror()
logging will cause assertion failures. (The same will go forinfo()
calls because we set up our mocks to always fail on non-mocked methods).However... moving all of this to use
slf4j-mock
is a bit of work, since we currently construct our mock/test objects in a@BeforeEach
-method with JUnit. I'd really prefer an "imperative" approach where I manually construct the object being tested. This is part of what the@BeforeEach
-method looks like at the moment:One of the main motivations for looking at
slf4j-mock
is to get rid of this ugly manuallogger
injection here in theTimescaleDBEventPopulator
constructor call. It would be really nice to just letslf4j-mock
provide the SLF4J implementation to the class, so that we could remove this constructor parameter altogether, but preferably without having to move our whole setup to use a@Mock
/@InjectMocks
-based approach.Sorry if what I'm trying to convey here might be a bit fuzzy. I think what I'm aiming for is mostly to minimize the impact on our existing test setup etc, if possible.
The text was updated successfully, but these errors were encountered: