Xcode keyboard shortcut: jump to test file?
Asked Answered
P

4

6

Is there an Xcode keyboard shortcut to jump from MyObject.m to MyObjectTests.m, and vice versa? If so, what is it?

Photochemistry answered 17/8, 2011 at 20:10 Comment(0)
S
1

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.

  1. 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

  2. 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!)

Swirsky answered 7/10, 2022 at 18:17 Comment(0)
D
0

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.

Discography answered 16/12, 2013 at 23:28 Comment(0)
H
0

If you always place your ClassTests next to its Class, you can use Control + 5 followed by Up/Down and Return. Three keystrokes. Not ideal but works.

Happ answered 21/12, 2013 at 22:36 Comment(0)
T
0

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:

  • MyObject.m
  • MyObject.h
  • MyObjectTests.m

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.

Tradein answered 30/7, 2015 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.