5 Must-Know Xcode Shortcuts for Unit Testing

栏目: IT技术 · 发布时间: 5年前

内容简介:Writing unit tests is a major part of the app development lifecycle. Xcode has some pretty useful built-in unit testing shortcuts, however, a lot of developers are not aware of their existence.In this article, I will show you 5 unit testing shortcuts where

Writing unit tests is a major part of the app development lifecycle. Xcode has some pretty useful built-in unit testing shortcuts, however, a lot of developers are not aware of their existence.

In this article, I will show you 5 unit testing shortcuts where you can leverage to improve your productivity while creating unit test cases or performing TDD.

Knowing the Mac Keyboard Symbols

Before we get started, here’s a quick revision of the Mac keyboard symbols.

5 Must-Know Xcode Shortcuts for Unit Testing
The Mac keyboard symbols

With all that in mind, let’s check out the 5 must-know shortcuts for unit testing.

Build and Run All Test Cases

⌘U (command + U)

⌘Uwill build and run all your test cases. It is the most commonly used shortcut when creating unit test cases.

It is equivalent to ⌘R (build & run) while doing app development. You can use this shortcut to build your test target and run all the test cases in your test target.

Build the Test Target

⇧⌘U (shift + command + U)

Hitting ⇧⌘U will trigger a build on the test target, note that this shortcut will not run your test cases .

Often you will use this shortcut to check for compile errors when creating unit test cases. It is equivalent to ⌘B (build only) while doing app development.

Run All the Test Cases

⌃⌘U (control + command + U)

Using ⌃⌘U will run all the test cases without building the test target . It is the opposite of ⇧⌘U.

This is especially useful when you want to skip a slow-building test target and jump straight into running all the test cases.

Run Previous Test Case(s)

⌃⌥⌘G (control + option + command + G)

You can use ⌃⌥⌘G to trigger your previously run test case. It is extremely useful when you are doing bug fixing because you can hit this shortcut to run the same test case again and again.

Do note that if your last test action is running the entire XCTestCase class, then hitting this shortcut will run the entire class again.

Run Selected Test Case

⌃⌥⌘U (control + option + command + U)

You can use ⌃⌥⌘U to trigger the test case where your text cursor is currently located.

5 Must-Know Xcode Shortcuts for Unit Testing
Run the selected test case

If your text cursor is highlighting an XCTestCase class, then all the test cases within that class will be run.

5 Must-Know Xcode Shortcuts for Unit Testing
Run all test cases within the selected XCTestCase class

Wrapping Up

It doesn’t matter if you are just fixing a minor bug or performing TDD on your next big app, able to leverage these 5 shortcuts efficiently can absolutely increase your daily productivity.

Here’s a summary of the 5 must-know Xcode shortcuts for unit testing.

Shortcut Action
⌘U Build and Run All Test Cases
⌃⌘U Build the Test Target (without running any test cases)
⌃⌘U Run All the Test Cases (without building the test target)
⌃⌥⌘G Run Previous Test Case(s)
⌃⌥⌘U Run Selected Test Case

Feel free to bookmark this article so that next time when you are working on any unit test related task, give these shortcuts a try, I am sure you will like it.

Further Readings

If you like this article, check out my previous article where I showcase the top 10 most useful Xcode shortcuts for navigation.

:link: Top 10 Most Useful Xcode Shortcuts for Navigation

Furthermore, you can also check out my otherarticles related to unit testing.

What do you think about these 5 shortcuts? Let me know in the comment section below. If you like this article, feel free to share it.

You can follow me on Twitter for more articles related to iOS development.

Thanks for reading and happy unit testing. ‍:computer:


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python机器学习基础教程

Python机器学习基础教程

[德]安德里亚斯·穆勒、[美]莎拉·吉多 / 张亮 / 人民邮电出版社 / 2018-1 / 79.00元

本书是机器学习入门书,以Python语言介绍。主要内容包括:机器学习的基本概念及其应用;实践中最常用的机器学习算法以及这些算法的优缺点;在机器学习中待处理数据的呈现方式的重要性,以及应重点关注数据的哪些方面;模型评估和调参的高级方法,重点讲解交叉验证和网格搜索;管道的概念;如何将前面各章的方法应用到文本数据上,还介绍了一些文本特有的处理方法。一起来看看 《Python机器学习基础教程》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具