为单元测试目标禁用* No visible @ interface *错误 [英] Disabling *No visible @interface* error for unit test target

查看:62
本文介绍了为单元测试目标禁用* No visible @ interface *错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类别(在 NSDate 上),该类别包含仅从该类别内的另一个方法调用的方法,因此无需在

I have a category (on NSDate) that contains a method that is only called from another method within the category, so there is no need to expose the method in the category's header file.

但是,正如预期的那样,如果我从单元测试中调用该方法,编译器会大声喊着

However, as expected, if I call the method from a unit test, the compiler shouts that


'NSDate'的可见@interface声明选择器'myMethod:'

No visible @interface for 'NSDate' declares the selector 'myMethod:'

I' d希望能够关闭这些特定的错误(当然,仅针对单元测试目标)。

I'd like to be able to turn off these particular errors (for the unit test target only, of course).

有人可以指出我正确的编译器标志的方向吗? ?

Can someone point me in the direction of the correct compiler flag?

推荐答案

不是关闭它们,而是为什么不重新声明呢?如果您完全关闭警告,则会丢失编译器将在真实位置发出警告的事实。

Instead of turning them off why not just redeclare it? If you turn the warnings off completely then you lose the fact that the compiler will give you warnings in genuine places.

因此,只需在单元测试上方声明它

So just declare it above the unit test

@interface NSDate (UnitTests)

// your method sig

@end

@implementation YourUnitTest

//...

这篇关于为单元测试目标禁用* No visible @ interface *错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆