我可以在目标c中为测试用例自定义stassert语句吗?
Can I white my own customize stassert statements for test cases in objective c?
最满意答案
如果您正在进行集成测试或涉及多个不同组件之间交互的测试,我理解很难确认某些行为是否发生 - 因为行为可能被隐藏或甚至没有记录在主代码中。
一种解决方案是编写用于记录行为或将内部状态暴露给测试单元的代码,并使用#ifdef来包围这样的代码块。
您可以将预处理器宏添加到调试模式的应用程序目标(而不是测试目标)的构建设置中。 但这可能是混淆的潜在根源。
If you are doing integration testing, or testing that involves interaction between several different components, I understand that it is hard to confirm that certain behavior happened or not - since the behavior might be hidden or not even recorded in the main code.
One solution is to write code that to record behavior or expose internal state to the testing unit, and use #ifdef to surround such block of code.
You can add the preprocessor macro to the build setting of the app target (not the test target) for the Debug mode. This can be a potential source of confusion, though.
更多推荐
发布评论