I'm writing a framework that also includes a simple logger that can be enabled/disabled at runtime. Since I want have unit tests for as much of the framework as possible, I also want to test whether the logger works correctly.
The logger simply logs via NSLog
. Now I need to test whether the output really matches the expectation (i.e. does it really log and is the output in the correct format). I couldn't find a way to do that using Xcode's XCTest framework.
I could modify the logger so that it doesn't use NSLog
while testing but that strikes me as error-prone. So, is there a better way to check the NSLog
output?
Have the logger output strings. Have another object print these. This way you can unit test the first object separately from the second.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With