Testing is a process we do along with our development. Knowing shortcuts would help you save some time, which will add up in the long run.
Menu Product > Test
or ⌘ - command + U
This command will run all tests in the current scheme.
Use it when you want to run all of your tests. This is the easiest to remember, and I use this all the time.
// Where testName is a test that our cursor poiting
Menu Product > Perform Action > Run <testName>
or ⌃ – control + ⌥ – option + ⌘ - command + U
This command runs a test case where your cursor is currently located.
If your cursor is on an XCTestCase class name or outside a test case, but within the scope of XCTestCase class, then all the test cases within that class will be run.
This shortcut is the same as running the test by click on the indicator next to each test method name.
I normally use this when I add a new test case. At the time, I finish writing my case, my cursor usually within a scope of the case. No need to move my cursor to that little indicator.
Menu Product > Perform Action > Run <testName> Again
or ⌃ – control + ⌥ – option + ⌘ - command + G
This is a very handy command. It reruns the last test method executed.
I use this when debugging my failed test case. You can edit your code and use this shortcut to run the last test without going back to your test case.
Menu Product > Build for > Testing
or ⇧ - SHIFT + ⌘ - command + U
This command will build the test bundle products without running the tests.
When develop a new feature. Building ⌘ - command + B and Runing ⌘ - command + R won't build your test bundle, so at the time you finish your feature, a lot of your tests might not even compile.
This command is useful when changing code to check for warnings and compile errors of your tests. The sooner you know the error, the easier to fix. I try to run this along with build command (but I always forgot the shortcut).
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.Become a patron Tweet Share
tintColor in SwiftUI
We will talk about accentColor, a tintColor equivalent in SwiftUI.
How to remove text from navigation bar back button
There are a lot of hacky ways to modify or remove a back button title. This tip will show you how to do it properly.