问题
I am writing unit tests for an app for iPhone using objective c. I want to use some variable only when compiling for test case for example
#ifdef UNIT_TESTING
@synthesize requestFinished, networkAvailable;//etc
#endif
now where should I define UNIT_TESTING that when I compile for unit tests it should enter this code block.... otherwise should go past it....
回答1:
Define it in the “Preprocessor Macros” build setting in each of your targets—especially the one where you want that macro defined, the unit test bundle target.
来源:https://stackoverflow.com/questions/3961938/using-variables-for-unit-testing-only