Is there a way to "Test" current file in Xcode4?
Asked Answered
E

2

5

Is there a way to "Test" current file in Xcode4?

That is if you are writting your 10th unit test, but rather than going TEST and having all unit tests run, you want to only trigger running those testing in the unit test file you are current in?

Ehrman answered 28/4, 2011 at 4:24 Comment(0)
F
2

It looks like Xcode 4 is heading that way, but it doesn't work well:

  • Edit scheme
  • Go to Test section
  • Expand to show checkboxes.

Unfortunately, you have to click individual checkboxes; there is no way to select the entire group, or even individual suites, and turn them off with a single click. Ideally, it would be nice to turn off everything, then reenable only the tests you want.

As a workaround, you can set up a test target containing the infrastructure to run any test, but not containing any tests. Call it something like "Ad-hoc Tests". Then take the test suite you want and temporarily add it to the target. Use the technique described above to turn off all tests in your main test target.

Faraway answered 2/5, 2011 at 21:15 Comment(0)
I
5

Pretty old post, but Xcode evolved since.

In Xcode6, got to Product > Perform Action
You'll see some other Test options, like Testing the current function.

The shortcut is Cmd-alt-ctrl-U. Pretty difficult with a single hand if you're not a pianist.

Iow answered 14/8, 2015 at 9:32 Comment(1)
To add on this, Cmd-Option-Ctrl-U will run a single test where your cursor is, and Cmd-Option-Ctrl-G will run all the last tests that were run.Mencher
F
2

It looks like Xcode 4 is heading that way, but it doesn't work well:

  • Edit scheme
  • Go to Test section
  • Expand to show checkboxes.

Unfortunately, you have to click individual checkboxes; there is no way to select the entire group, or even individual suites, and turn them off with a single click. Ideally, it would be nice to turn off everything, then reenable only the tests you want.

As a workaround, you can set up a test target containing the infrastructure to run any test, but not containing any tests. Call it something like "Ad-hoc Tests". Then take the test suite you want and temporarily add it to the target. Use the technique described above to turn off all tests in your main test target.

Faraway answered 2/5, 2011 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.