What is the best way to unit test code that's behaviour changes based on an ifdef?
e.g.
+ (NSString*) someMethod:(NSString*)value {
//Do some stuff ...
#ifdef DEBUG
//Tell user about error
#else
//Suppress error
#endif
}
you should only need to test release build because this what the user see.
to actually answer your question: you can split the method to 3 method
+ (NSString*) someMethod:(NSString*)value {
#ifdef DEBUG
return [self someMethod_debug:value];
#else
return [self someMethod_release:value];
#endif
}
+ (void)someMethod_debug:(NSString *)value {
//Do some stuff ...
//Tell user about error
}
+ (void)someMethod_release:(NSString *)value {
//Do some stuff ...
//Suppress error
}
then you can test someMethod_debug and someMethod_release individually
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