The code that I am testing uses the Project object’s logger to log information. I would like to be able to set a logger in the Project object so that in my unit test I can also capture logging from the method itself to help debug test failures for example.
e.g. capture the following debug statement XYZ when I test that method:
public Object myMethodThatIAMTesting(Project project, ...)
{
...
project.logger.debug("XYZ")
...
}
Doing project.setProperty(‘logger’, Object) says I can’t set a read only value… and I can’t figure out what Object to put to satisfy doing project.getLogging().addStandardOutputListener( ??? )
So how do I do this? I can’t seem to figure it out
Since we’re talking about unit testing, perhaps there is a way to refactor the code a little bit to make it easier to test? Wrap the call in something verifiable or use a mocking framework?