Xcode 键盘快捷键:跳转到测试文件?
是否有 Xcode 键盘快捷键可以从 MyObject.m
跳转到 MyObjectTests.m
,反之亦然?如果是这样,那是什么?
Is there an Xcode keyboard shortcut to jump from MyObject.m
to MyObjectTests.m
, and vice versa? If so, what is it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您已经知道相关测试所在的测试文件的名称,那么上述答案当然可以很好地工作。但是,如果您不知道测试在哪里(例如当您继承了旧代码库时或者距离编写代码已经超过 2 天),有两种方法可以实现。
键盘快捷键 ctrl-cmd-up 将带您进入该文件的“生成的界面”(objc 时代遗留下来的),但再次按下它将带您进入关联的测试文件
使用助理编辑器,可以通过右上角的小菜单或键盘快捷键 ctrl-opt-cmd-enter 打开它。这通常会显示关联文件的测试文件(如果您正在查找测试文件,反之亦然!)
If you already know the name of the test file where the relevant tests are located, then of course the above answers work well. But if you don't know where the tests are (such as when you inherited an old code base or it's been more than 2 days since you wrote it), there are two ways to do it.
The keyboard shortcut ctrl-cmd-up will take you to the "generated interface" (a leftover from the objc days) for that file, but pressing it a second time will take you to the associated test file
Use the assistant editor, which can be turned on either through the little menu in the top right corner, or through the keyboard shortcut ctrl-opt-cmd-enter. This will usually show the test file for an associated file (or vice versa if you're looking a test file!)
我还没有找到办法做到这一点。我认为功能请求材料。
在“项目导航器”底部,您可以在搜索区域中输入文件名,以动态搜索您感兴趣的文件。它们将在您输入时进行过滤。
I haven't found a way to do this. Feature request material I think.
At the bottom of "Project Navigator" you can type your filename in the search area to dynamically search for files you would be interested in. They will be filtered as you type.
如果您始终将
ClassTests
放在其Class
旁边,则可以使用 Control + 5 后跟 向上/向下 和返回。三个按键。不理想但有效。If you always place your
ClassTests
next to itsClass
, you can use Control + 5 followed by Up/Down and Return. Three keystrokes. Not ideal but works.Command + Shift + O 效果相当好。这是一个快速打开的命令,因此您可以输入文件名并获取以下列表:
它也会记住您上次输入的内容,因此下次您命令 + Shift + O (在同一个 XCode 实例中)您现在可以向下箭头两次并返回以从源获取到测试文件。适用于 XCode 6.3 / 6.4;我不确定其他版本。
Command + Shift + O works fairly well. It is an open quickly command, so you can type in the name of the file and get a list of:
It remembers what you typed last too, so next time you Command + Shift + O (in the same XCode instance) you can now down arrow twice and return to get from source to test file. Works in XCode 6.3 / 6.4; I am not sure about other versions.