STAssert*() 宏内的 Xcode 补全
我已经开始使用 Xcode4 的 SenTest 单元测试工具。它一直工作得很好,但是......
Xcode 没有在 STAssert*()
宏内提供代码完成建议。
我喜欢将简单的表达式直接写入断言中,以节省击键次数和屏幕空间:
STAssertTrue(mydoc.isInitialized, nil);
STAssertTrue(mydoc.pageCount == 2, nil);
我遇到的问题是,当我在断言中写入表达式时,Xcode 不提供代码完成功能。
在单元测试的上下文中,这是一个很大的遗憾,在单元测试中,代码完成可以是一种快速而方便的方法,可以提醒自己需要为其编写断言的剩余属性和方法。更不用说通常完成的好处了。
所以我开始像这样编写我的断言,这样我就可以完成代码:
BOOL b = NO;
b = mydoc.isInitialized;
STAssertTrue(b, nil);
b = mydoc.pageCount == 2;
STAssertTrue(b, nil);
我真的不想做这种事情。它更冗长,更难阅读,并且使得 Xcode 的单元测试失败消息的意义更小。
有什么想法吗?我已经删除了我的派生数据目录,重新启动了 Xcode,清理,重建等。
I've started using Xcode4's SenTest unit testing facilities. It's been working pretty well, but ...
Xcode isn't offering code completion suggestions inside STAssert*()
macros.
I like to write simple expressions right into the assert, to save keystrokes and screen real estate:
STAssertTrue(mydoc.isInitialized, nil);
STAssertTrue(mydoc.pageCount == 2, nil);
The problem I'm having is that Xcode isn't offering code completion while I'm writing the expression inside the asserts.
This is a big bummer in the context of unit tests, where code completion can be a rapid and convenient way to remind yourself of the remaining properties and methods you need to write asserts for. Not to mention the usual benefits of completion.
So I've taken to writing my asserts like this, so I can get the code completion:
BOOL b = NO;
b = mydoc.isInitialized;
STAssertTrue(b, nil);
b = mydoc.pageCount == 2;
STAssertTrue(b, nil);
I'd really rather not have to do this kind of thing. It's more verbose, it's harder to read, and it makes Xcode's unit test failure messages less meaningful.
Any ideas? I've deleted my derived data dir, rebooted Xcode, cleaned, rebuilt, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是真正的答案,而是建议:
你说这会让你的代码更冗长、更难阅读?为什么不为您的占位符变量使用有意义的名称,这样您就可以提高测试的可读性,例如
Not really an answer but a suggestion:
You say it makes your code more verbose and harder to read? Why not use meaningful names for your
place holder
variables and you can possibly increase the readability of your tests e.g.