Choosing Which XCTestCases to Run
Xcode's Test Navigator (
cmd + 5), is an outline of your tests. As you mouse over the elements in this outline, you'll see a run button off to the right. Using this button you can pick an individual case, file or target to run.
While editing a test file, you can use the buttons in the gutter to run either an individual case or the entire file.
But if you want more control, you can shift or command click on test cases in the Test Navigator to highlight them and then command click to bring up even more options:
We can choose to run both highlighted cases or even disable them. Nice.
But, what about keyboard shortcuts??
You can run the entire suite with
cmd + u, but did you know about these others:
ctrl + opt + cmd + u- Run the test file currently open.
ctrl + opt + cmd + g- Rerun the test(s) you just ran.
That last shortcut can be really helpful. Once you've run a particular test case in isolation, you can use that shortcut to run it over and over as you work.Tweet