什么是 iOS 测试框架?

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

使用 iOS 测试框架的重要性

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支:iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) 维修费用:应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 分析使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 资源利用:使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

顶级 iOS 测试框架

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 底线

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey 是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战 Bottom line

底线

TestProject is an awesome free framework and has garnered positive reviews from all around the world. It is easy to understand and takes no time in setting up the configurations.

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

The best TestProject advantage is that it does not force the testers to use any specific platform or language. If you are interested in writing the code yourself, it supports all popular programming languages- Python, Java, JavaScript & C#. The flexibility of the framework makes it a must-try iOS testing framework.

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey EarlGrey is an open source iOS testing framework developed by Google to test their native iOS applications which include YouTube, Google Calendar, etc 🍵 EarlGrey 1.0 is now officially deprecated and version 2.0 is recommended for the iOS testers.

是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

With EarlGrey 2.0, the testers can combine their EarlGrey tests with XCUITest which is Apple’s official testing framework. Also, as stated in Google’s official documentation, “EarlGrey 2.0 uses UI testing target and not unit testing as a target like in EarlGrey 1.0”.

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

EarlGrey Pros

优点

EarlGrey’s synchronization features are excellent and can synchronize automatically with the network and UI components. EarlGrey 的同步特性非常优秀,可以自动与网络和 UI 组件同步 The testers can also set their own timing if required. 如果需要,测试人员还可以设置自己的计时 EarlGrey improves the test’s stability as the actions are performed after the UI settles into a steady state. EarlGrey 提高了测试的稳定性,因为操作是在 UI 进入稳定状态后执行的 EarlGrey’s tests can be run directly from XCode or through the command line. EarlGrey 的测试可以直接从 XCode 或通过命令行运行 Open source in nature. 自然界中的开源 Cons

缺点

May require additional coding in the application to support some of the APIs. 可能需要在应用程序中进行额外的编码,以支持某些 api Google fetches the tests executions and other test analytics from the testers. This can be turned off but not all of the testers are aware of it. 从测试人员那里获取测试执行和其他测试分析。这可以关闭,但并不是所有的测试人员都知道它 是一个很好的 iOS 应用测试框架。然而,EarlGrey 非常容易与 Google 应用程序融合,而与其他本地应用程序融合则不那么容易。它的学习曲线很浅,它的优势来自于它与 UI 测试元素 XCode 和 XCUITest 的混合能力。

XCTest/XCUITest XCTest 是苹果的 iOS 测试框架,与 XCode 完全兼容(并与 XCode 并行发布)。XCTest 非常通用,可以在各种级别上执行测试,例如单元测试、性能测试和用户界面测试。

main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战 Bottom line

底线

TestProject is an awesome free framework and has garnered positive reviews from all around the world. It is easy to understand and takes no time in setting up the configurations.

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

The best TestProject advantage is that it does not force the testers to use any specific platform or language. If you are interested in writing the code yourself, it supports all popular programming languages- Python, Java, JavaScript & C#. The flexibility of the framework makes it a must-try iOS testing framework.

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey EarlGrey is an open source iOS testing framework developed by Google to test their native iOS applications which include YouTube, Google Calendar, etc 🍵 EarlGrey 1.0 is now officially deprecated and version 2.0 is recommended for the iOS testers.

是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

With EarlGrey 2.0, the testers can combine their EarlGrey tests with XCUITest which is Apple’s official testing framework. Also, as stated in Google’s official documentation, “EarlGrey 2.0 uses UI testing target and not unit testing as a target like in EarlGrey 1.0”.

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

EarlGrey Pros

优点

EarlGrey’s synchronization features are excellent and can synchronize automatically with the network and UI components. EarlGrey 的同步特性非常优秀,可以自动与网络和 UI 组件同步 The testers can also set their own timing if required. 如果需要,测试人员还可以设置自己的计时 EarlGrey improves the test’s stability as the actions are performed after the UI settles into a steady state. EarlGrey 提高了测试的稳定性,因为操作是在 UI 进入稳定状态后执行的 EarlGrey’s tests can be run directly from XCode or through the command line. EarlGrey 的测试可以直接从 XCode 或通过命令行运行 Open source in nature. 自然界中的开源 Cons

缺点

May require additional coding in the application to support some of the APIs. 可能需要在应用程序中进行额外的编码,以支持某些 api Google fetches the tests executions and other test analytics from the testers. This can be turned off but not all of the testers are aware of it. 从测试人员那里获取测试执行和其他测试分析。这可以关闭,但并不是所有的测试人员都知道它 Code example

代码示例

var firstMatch = 1.1true 真的 let matches: MatchesBlock = 2.1.1.1{ (element: AnyObject! 元素: AnyObject) -> Bool 女名女子名in 在 if 如果 firstMatch { firstMatch = 第一匹配 =false 虚假的 return 返回 true 真的 } return 返回 false 虚假的 } Source: EarlGrey examples from the official repo.

来源: 官方回购的 EarlGrey 案例。

Bottom line

底线

EarlGrey is a great testing framework for iOS applications. However, EarlGrey does blend very easily with Google applications and not so easily with other native applications. It has a shallow learning curve and its strength comes from its mingling powers with UI test elements, XCode and XCUITest.

是一个很好的 iOS 应用测试框架。然而,EarlGrey 非常容易与 Google 应用程序融合,而与其他本地应用程序融合则不那么容易。它的学习曲线很浅,它的优势来自于它与 UI 测试元素 XCode 和 XCUITest 的混合能力。

XCTest / XCUITest XCTest/XCUITest XCTest is Apple’s iOS testing framework that’s fully compatible with XCode (and is released in parallel to XCode). XCTest is very versatile and can perform tests on various levels such as unit tests, performance tests and user interface tests ✅ XCUITest can be considered as a sub-class of XCTest and works specifically towards the user interface of the application.

XCTest 是苹果的 iOS 测试框架,与 XCode 完全兼容(并与 XCode 并行发布)。XCTest 非常通用,可以在各种级别上执行测试,例如单元测试、性能测试和用户界面测试。

XCTest / XCUITest Pros

优点

XCTest provides a single solution to a variety of tests. XCTest 为各种测试提供了单一的解决方案 For iOS app developers, the testing becomes very easy due to the same language. 对于 iOS 应用程序开发者来说,由于使用相同的语言,测试变得非常容易 The test execution is faster than other iOS testing frameworks. 测试执行比其他 iOS 测试框架更快 XCTest has a shallow learning curve and can be grasped easily given that the tester is familiar with Objective-C/Swift. 由于测试人员熟悉 Objective-C/Swift,因此 XCTest 的学习曲线较浅,易于掌握 XCUITest provides UI recording capabilities and generating code out from it. XCUITest 提供 UI 记录功能,并从中生成代码 Easier to deal with CI/CD tools and get seamless integration. 更容易处理 CI/CD 工具并实现无缝集成 Cons

缺点

Limited language support. Unfamiliar testers might have to go through a learning phase which can take time. 有限的语言支持。不熟悉的测试人员可能要经历一个需要时间的学习阶段 XCTest/XCUITest does not have cross-platform support. XCTest/XCUITest 没有跨平台支持 Only technical testers with a programming background can perform testing on XCTest. 只有具有编程背景的技术测试人员才能在 XCTest 上执行测试 Deeplinking is not supported by XCTest/XCUITest. XCTest/XCUITest 不支持深度跳转 XCTest/XCUITest 类似于苹果的所有功能。它是一个封闭的 iOS 测试框架,有编程方面的限制。对于那些熟悉在跨平台框架上用自己选择的语言测试 iOS 应用程序的人来说,这是一个很大的缺点。老实说,XCTest 非常适合那些开发 iOS 应用程序和使用 XCode 进行开发的人。

Detox Detox 是一个端到端的测试工具,它使用灰盒测试来控制像 Appium 这样的黑盒测试工具的片状和不可预测的行为

。首先,它可以在应用程序在模拟器上运行时对其进行测试,因此就像真正的用户正在发现缺陷一样工作。其次,Detox 是基于 Javascript 的,因此你可以运行任何支持它的东西。

main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战 Bottom line

底线

TestProject is an awesome free framework and has garnered positive reviews from all around the world. It is easy to understand and takes no time in setting up the configurations.

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

The best TestProject advantage is that it does not force the testers to use any specific platform or language. If you are interested in writing the code yourself, it supports all popular programming languages- Python, Java, JavaScript & C#. The flexibility of the framework makes it a must-try iOS testing framework.

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey EarlGrey is an open source iOS testing framework developed by Google to test their native iOS applications which include YouTube, Google Calendar, etc 🍵 EarlGrey 1.0 is now officially deprecated and version 2.0 is recommended for the iOS testers.

是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

With EarlGrey 2.0, the testers can combine their EarlGrey tests with XCUITest which is Apple’s official testing framework. Also, as stated in Google’s official documentation, “EarlGrey 2.0 uses UI testing target and not unit testing as a target like in EarlGrey 1.0”.

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

EarlGrey Pros

优点

EarlGrey’s synchronization features are excellent and can synchronize automatically with the network and UI components. EarlGrey 的同步特性非常优秀,可以自动与网络和 UI 组件同步 The testers can also set their own timing if required. 如果需要,测试人员还可以设置自己的计时 EarlGrey improves the test’s stability as the actions are performed after the UI settles into a steady state. EarlGrey 提高了测试的稳定性,因为操作是在 UI 进入稳定状态后执行的 EarlGrey’s tests can be run directly from XCode or through the command line. EarlGrey 的测试可以直接从 XCode 或通过命令行运行 Open source in nature. 自然界中的开源 Cons

缺点

May require additional coding in the application to support some of the APIs. 可能需要在应用程序中进行额外的编码,以支持某些 api Google fetches the tests executions and other test analytics from the testers. This can be turned off but not all of the testers are aware of it. 从测试人员那里获取测试执行和其他测试分析。这可以关闭,但并不是所有的测试人员都知道它 Code example

代码示例

var firstMatch = 1.1true 真的 let matches: MatchesBlock = 2.1.1.1{ (element: AnyObject! 元素: AnyObject) -> Bool 女名女子名in 在 if 如果 firstMatch { firstMatch = 第一匹配 =false 虚假的 return 返回 true 真的 } return 返回 false 虚假的 } Source: EarlGrey examples from the official repo.

来源: 官方回购的 EarlGrey 案例。

Bottom line

底线

EarlGrey is a great testing framework for iOS applications. However, EarlGrey does blend very easily with Google applications and not so easily with other native applications. It has a shallow learning curve and its strength comes from its mingling powers with UI test elements, XCode and XCUITest.

是一个很好的 iOS 应用测试框架。然而,EarlGrey 非常容易与 Google 应用程序融合,而与其他本地应用程序融合则不那么容易。它的学习曲线很浅,它的优势来自于它与 UI 测试元素 XCode 和 XCUITest 的混合能力。

XCTest / XCUITest XCTest/XCUITest XCTest is Apple’s iOS testing framework that’s fully compatible with XCode (and is released in parallel to XCode). XCTest is very versatile and can perform tests on various levels such as unit tests, performance tests and user interface tests ✅ XCUITest can be considered as a sub-class of XCTest and works specifically towards the user interface of the application.

XCTest 是苹果的 iOS 测试框架,与 XCode 完全兼容(并与 XCode 并行发布)。XCTest 非常通用,可以在各种级别上执行测试,例如单元测试、性能测试和用户界面测试。

XCTest / XCUITest Pros

优点

XCTest provides a single solution to a variety of tests. XCTest 为各种测试提供了单一的解决方案 For iOS app developers, the testing becomes very easy due to the same language. 对于 iOS 应用程序开发者来说,由于使用相同的语言,测试变得非常容易 The test execution is faster than other iOS testing frameworks. 测试执行比其他 iOS 测试框架更快 XCTest has a shallow learning curve and can be grasped easily given that the tester is familiar with Objective-C/Swift. 由于测试人员熟悉 Objective-C/Swift,因此 XCTest 的学习曲线较浅,易于掌握 XCUITest provides UI recording capabilities and generating code out from it. XCUITest 提供 UI 记录功能,并从中生成代码 Easier to deal with CI/CD tools and get seamless integration. 更容易处理 CI/CD 工具并实现无缝集成 Cons

缺点

Limited language support. Unfamiliar testers might have to go through a learning phase which can take time. 有限的语言支持。不熟悉的测试人员可能要经历一个需要时间的学习阶段 XCTest/XCUITest does not have cross-platform support. XCTest/XCUITest 没有跨平台支持 Only technical testers with a programming background can perform testing on XCTest. 只有具有编程背景的技术测试人员才能在 XCTest 上执行测试 Deeplinking is not supported by XCTest/XCUITest. XCTest/XCUITest 不支持深度跳转 Code example

代码示例

class TableValidationTests: XCTestCase 类 TableValidationTests: XCTestCase{ /// Tests that a new table instance has zero rows and columns. //测试新表实例是否具有零行和零列 func 真菌testEmptyTableRowAndColumnCount 和 columncount() { let table = 让表 =Table 表() XCTAssertEqual(table. 表rowCount, 0, "Row count was not zero." “行数不是零。”) XCTAssertEqual(table. 表columnCount 柱状数, 0, "Column count was not zero." ”列计数不为零。”) } } Source: Official XCTest documentation

来源: 官方 XCTest 文档

Bottom line

底线

XCTest/XCUITest is similar to what everything has been with Apple. It is a closed iOS testing framework with programming limitations. This is a great disadvantage with people familiar with testing iOS apps on cross-platform frameworks with the language of their choice. Honestly, XCTest is perfect for those who have developed iOS applications and work with XCode for their development purposes.

XCTest/XCUITest 类似于苹果的所有功能。它是一个封闭的 iOS 测试框架,有编程方面的限制。对于那些熟悉在跨平台框架上用自己选择的语言测试 iOS 应用程序的人来说,这是一个很大的缺点。老实说,XCTest 非常适合那些开发 iOS 应用程序和使用 XCode 进行开发的人。

Detox 排毒 Detox is an end-to-end testing tool that uses gray box testing to control the flakiness and unpredictable behavior of black-box testing tools such as Appium 🤖

Detox 是一个端到端的测试工具,它使用灰盒测试来控制像 Appium 这样的黑盒测试工具的片状和不可预测的行为

Detox comes with two very strong USPs. First, it can test an application while it is running on the simulator and therefore works as if a real user is finding the defects. Second, Detox is Javascript based and therefore you can run anything that supports it.

排毒有两个很强的毒副作用。首先,它可以在应用程序在模拟器上运行时对其进行测试,因此就像真正的用户正在发现缺陷一样工作。其次,Detox 是基于 Javascript 的,因此你可以运行任何支持它的东西。

Detox Pros

优点

Detox comes with cross-platform support. 排毒带有跨平台的支持 Can test an application just like a real user. 可以像真正的用户一样测试应用程序 Advanced monitoring reduces the flakiness of the tool. 先进的监控减少了工具的脆弱性 Very high and smooth support for continuous integration tools. 对持续集成工具的高度和流畅的支持 Does not depend on Webdriver for testing support. 不依赖于 Webdriver 的测试支持 Uses very simple and easy-to-use APIs written in Javascript. 使用用 Javascript 编写的非常简单易用的 api Open source with a lot of contributions since its inception. 开放源码,从一开始就有很多贡献 Cons

缺点

Testing on real iOS devices is still not supported. 在真正的 iOS 设备上测试仍然不被支持

。它是灰盒测试,并使用 Javascript (当今世界最流行的语言之一)执行端到端测试。所以,竖起大拇指吧!我发现 Detox 唯一的问题是它不支持 iOS 真实设备测试,并且使用模拟器来实现同样的功能。

使用模拟器也不错,但不能检查应用程序的质量比一个真正的设备更好。因此,我认为这个因素对于许多测试人员来说都是一个阻碍因素。

Calabash Calabash 在 iOS 测试框架清单和社区中很有名气,因为它的稳定性和测试构建的方法。Calabash 使用 Cucumber,它使非技术人员能够轻松构造测试。 Calabash 提供了一长串语言支持,可以在 iOS 和 Android 应用程序上运行。

LinkedIn Twitter Email main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战 Bottom line

底线

TestProject is an awesome free framework and has garnered positive reviews from all around the world. It is easy to understand and takes no time in setting up the configurations.

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

The best TestProject advantage is that it does not force the testers to use any specific platform or language. If you are interested in writing the code yourself, it supports all popular programming languages- Python, Java, JavaScript & C#. The flexibility of the framework makes it a must-try iOS testing framework.

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey EarlGrey is an open source iOS testing framework developed by Google to test their native iOS applications which include YouTube, Google Calendar, etc 🍵 EarlGrey 1.0 is now officially deprecated and version 2.0 is recommended for the iOS testers.

是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

With EarlGrey 2.0, the testers can combine their EarlGrey tests with XCUITest which is Apple’s official testing framework. Also, as stated in Google’s official documentation, “EarlGrey 2.0 uses UI testing target and not unit testing as a target like in EarlGrey 1.0”.

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

EarlGrey Pros

优点

EarlGrey’s synchronization features are excellent and can synchronize automatically with the network and UI components. EarlGrey 的同步特性非常优秀,可以自动与网络和 UI 组件同步 The testers can also set their own timing if required. 如果需要,测试人员还可以设置自己的计时 EarlGrey improves the test’s stability as the actions are performed after the UI settles into a steady state. EarlGrey 提高了测试的稳定性,因为操作是在 UI 进入稳定状态后执行的 EarlGrey’s tests can be run directly from XCode or through the command line. EarlGrey 的测试可以直接从 XCode 或通过命令行运行 Open source in nature. 自然界中的开源 Cons

缺点

May require additional coding in the application to support some of the APIs. 可能需要在应用程序中进行额外的编码,以支持某些 api Google fetches the tests executions and other test analytics from the testers. This can be turned off but not all of the testers are aware of it. 从测试人员那里获取测试执行和其他测试分析。这可以关闭,但并不是所有的测试人员都知道它 Code example

代码示例

var firstMatch = 1.1true 真的 let matches: MatchesBlock = 2.1.1.1{ (element: AnyObject! 元素: AnyObject) -> Bool 女名女子名in 在 if 如果 firstMatch { firstMatch = 第一匹配 =false 虚假的 return 返回 true 真的 } return 返回 false 虚假的 } Source: EarlGrey examples from the official repo.

来源: 官方回购的 EarlGrey 案例。

Bottom line

底线

EarlGrey is a great testing framework for iOS applications. However, EarlGrey does blend very easily with Google applications and not so easily with other native applications. It has a shallow learning curve and its strength comes from its mingling powers with UI test elements, XCode and XCUITest.

是一个很好的 iOS 应用测试框架。然而,EarlGrey 非常容易与 Google 应用程序融合,而与其他本地应用程序融合则不那么容易。它的学习曲线很浅,它的优势来自于它与 UI 测试元素 XCode 和 XCUITest 的混合能力。

XCTest / XCUITest XCTest/XCUITest XCTest is Apple’s iOS testing framework that’s fully compatible with XCode (and is released in parallel to XCode). XCTest is very versatile and can perform tests on various levels such as unit tests, performance tests and user interface tests ✅ XCUITest can be considered as a sub-class of XCTest and works specifically towards the user interface of the application.

XCTest 是苹果的 iOS 测试框架,与 XCode 完全兼容(并与 XCode 并行发布)。XCTest 非常通用,可以在各种级别上执行测试,例如单元测试、性能测试和用户界面测试。

XCTest / XCUITest Pros

优点

XCTest provides a single solution to a variety of tests. XCTest 为各种测试提供了单一的解决方案 For iOS app developers, the testing becomes very easy due to the same language. 对于 iOS 应用程序开发者来说,由于使用相同的语言,测试变得非常容易 The test execution is faster than other iOS testing frameworks. 测试执行比其他 iOS 测试框架更快 XCTest has a shallow learning curve and can be grasped easily given that the tester is familiar with Objective-C/Swift. 由于测试人员熟悉 Objective-C/Swift,因此 XCTest 的学习曲线较浅,易于掌握 XCUITest provides UI recording capabilities and generating code out from it. XCUITest 提供 UI 记录功能,并从中生成代码 Easier to deal with CI/CD tools and get seamless integration. 更容易处理 CI/CD 工具并实现无缝集成 Cons

缺点

Limited language support. Unfamiliar testers might have to go through a learning phase which can take time. 有限的语言支持。不熟悉的测试人员可能要经历一个需要时间的学习阶段 XCTest/XCUITest does not have cross-platform support. XCTest/XCUITest 没有跨平台支持 Only technical testers with a programming background can perform testing on XCTest. 只有具有编程背景的技术测试人员才能在 XCTest 上执行测试 Deeplinking is not supported by XCTest/XCUITest. XCTest/XCUITest 不支持深度跳转 Code example

代码示例

class TableValidationTests: XCTestCase 类 TableValidationTests: XCTestCase{ /// Tests that a new table instance has zero rows and columns. //测试新表实例是否具有零行和零列 func 真菌testEmptyTableRowAndColumnCount 和 columncount() { let table = 让表 =Table 表() XCTAssertEqual(table. 表rowCount, 0, "Row count was not zero." “行数不是零。”) XCTAssertEqual(table. 表columnCount 柱状数, 0, "Column count was not zero." ”列计数不为零。”) } } Source: Official XCTest documentation

来源: 官方 XCTest 文档

Bottom line

底线

XCTest/XCUITest is similar to what everything has been with Apple. It is a closed iOS testing framework with programming limitations. This is a great disadvantage with people familiar with testing iOS apps on cross-platform frameworks with the language of their choice. Honestly, XCTest is perfect for those who have developed iOS applications and work with XCode for their development purposes.

XCTest/XCUITest 类似于苹果的所有功能。它是一个封闭的 iOS 测试框架,有编程方面的限制。对于那些熟悉在跨平台框架上用自己选择的语言测试 iOS 应用程序的人来说,这是一个很大的缺点。老实说,XCTest 非常适合那些开发 iOS 应用程序和使用 XCode 进行开发的人。

Detox 排毒 Detox is an end-to-end testing tool that uses gray box testing to control the flakiness and unpredictable behavior of black-box testing tools such as Appium 🤖

Detox 是一个端到端的测试工具,它使用灰盒测试来控制像 Appium 这样的黑盒测试工具的片状和不可预测的行为

Detox comes with two very strong USPs. First, it can test an application while it is running on the simulator and therefore works as if a real user is finding the defects. Second, Detox is Javascript based and therefore you can run anything that supports it.

排毒有两个很强的毒副作用。首先,它可以在应用程序在模拟器上运行时对其进行测试,因此就像真正的用户正在发现缺陷一样工作。其次,Detox 是基于 Javascript 的,因此你可以运行任何支持它的东西。

Detox Pros

优点

Detox comes with cross-platform support. 排毒带有跨平台的支持 Can test an application just like a real user. 可以像真正的用户一样测试应用程序 Advanced monitoring reduces the flakiness of the tool. 先进的监控减少了工具的脆弱性 Very high and smooth support for continuous integration tools. 对持续集成工具的高度和流畅的支持 Does not depend on Webdriver for testing support. 不依赖于 Webdriver 的测试支持 Uses very simple and easy-to-use APIs written in Javascript. 使用用 Javascript 编写的非常简单易用的 api Open source with a lot of contributions since its inception. 开放源码,从一开始就有很多贡献 Cons

缺点

Testing on real iOS devices is still not supported. 在真正的 iOS 设备上测试仍然不被支持 Code example

代码示例

describe 描述('Login flow' 登录流程, () => {
it 它('should login successfully' 应该成功登录, async 异步的 () => { await device. 等待装置reloadReactNative();
await 等待element 元素(by. 通过id 身份证('email' ‘ em ail’)).typeText('john@example.com'); await 等待element 元素(by. 通过id 身份证('password' 密码)).typeText('123456' 123456); await 等待element 元素(by. 通过text 文本('Login' “登录”)).tap 踢踏舞();
await 等待expect 期待(element 元素(by. 通过text 文本('Welcome' 欢迎))).toBeVisible(); await 等待expect 期待(element 元素(by. 通过id 身份证('email' ‘ em ail’))).toNotExist(); });
}); Source: Official Detox Repo

来源: 官方排毒回收站

Bottom line: Detox brings important things to the table. It is gray box testing and performs end-to-end testing using Javascript which is one of the most popular languages in the world today. So, thumbs up for that! The only problem I find with Detox is that it does not support iOS real device testing and uses a simulator to achieve the same.

底线: 排毒可以把重要的事情摆到桌面上。它是灰盒测试,并使用 Javascript (当今世界最流行的语言之一)执行端到端测试。所以,竖起大拇指吧!我发现 Detox 唯一的问题是它不支持 iOS 真实设备测试,并且使用模拟器来实现同样的功能。

Using a simulator is also good but cannot check the quality of the application better than a real device. Therefore, I think this factor can be a deal-breaker for many testers.

使用模拟器也不错,但不能检查应用程序的质量比一个真正的设备更好。因此,我认为这个因素对于许多测试人员来说都是一个阻碍因素。

Calabash 葫芦 Calabash is a big name among the iOS testing frameworks listings and communities because of its stability and approach towards the construction of the tests. Calabash uses Cucumber, which enables non-tech people to constructs tests easily 💫 Calabash comes with a long list of language support and can run on iOS as well as Android applications.

Calabash 在 iOS 测试框架清单和社区中很有名气,因为它的稳定性和测试构建的方法。Calabash 使用 Cucumber,它使非技术人员能够轻松构造测试。 Calabash 提供了一长串语言支持,可以在 iOS 和 Android 应用程序上运行。

Calabash Pros

优点

Open source and one of the major iOS testing frameworks in focus. Hence, continuous development. 开源和一个主要的 iOS 测试框架,因此,持续开发 Supports Python, C#, PHP, Ruby, Perl, and many more. 支持 Python,c # ,PHP,Ruby,Perl 等等 Constructs tests with the BDD approach which is extremely helpful for non-tech people. 使用 BDD 方法构建测试,这对非技术人员非常有帮助 It’s a cross-platform testing framework and hence enables tests across platforms without creating newer ones. 它是一个跨平台的测试框架,因此支持跨平台的测试,而不需要创建更新的测试 Supports iOS emulators as well as physical devices. 支持 iOS 模拟器和物理设备 Calabash is known to be a very stable iOS testing framework. 众所周知葫芦是一个非常稳定的 iOS 测试框架 Cons

缺点

Calabash requires coding outside its BDD bubble. 葫芦需要在它的 BDD 气泡之外进行编码 Takes time to run the application. 运行应用程序需要时间 Does not have a very large community to help. 没有很大的社区可以帮助 葫芦已经获得了大量的普及,这背后的主要原因是对 BDD 方法的支持。

BDD 总是受到人们的青睐,因为它可以在不学习编程语言和创建复杂逻辑的情况下完成任务。但是有编程背景的人经常出于同样的原因批评 Calabash。与 Appium 相比,卡拉巴什也没有一个大的社区。

OCMock 是一个开源项目,通过创建模拟对象来增强 iOS 测试方法。OCMock 代表 Objective-C Mock,这意味着测试人员可以使用 Objective-C 语言创建模拟对象

正在积极开发 OCMock,它包括三种类型的模拟—— stub、动态模拟和部分模拟。这些例子和定义可以在 OCMock 官方网站上学习。

Pros

优点

Easy learning curve and easy to create objects of various types. 简单的学习曲线,易于创建各种类型的对象 Extensive documentation to help the testers. 大量的文档来帮助测试人员 iOS app development and OCMock both use Objective-C and therefore it becomes easier to work with OCMock. iOS 应用程序开发和 OCMock 都使用 Objective-C,因此使用 OCMock 更加容易 It’s an open source framework and therefore sees an active development from people all around the world. 它是一个开源框架,因此看到了来自世界各地人们的积极发展 Cons

缺点

Just to mock objects. Does not provide a complete iOS testing solution. 不提供完整的 iOS 测试解决方案 不是一个测试框架,但是可以与许多测试框架一起工作。在其文档中,OCMock 没有提到它是一个“测试框架”或“测试解决方案”。尽管如此,OCMock 确实提到了增强 XCTest 和其他支持它的框架的能力。

所以,如果你已经知道一个 iOS 测试框架,并且想通过添加 OCMock 来增强它,那么它实际上是一个很好的选择,并且在创建模拟对象方面很有帮助。但是,如果您期望使用 OCMock 获得一个完整的测试解决方案,那么您将会失望。

KIF KIF 是为 iOS 应用程序设计的集成测试框架。KIF 代表“保持功能性”,用于 iOS 应用程序上的 UI 测试。KIF 使用 XCTest 目标来构建自动化测试。尽管如此,它确实使用了未登记的原料药,因此绝不应该用于生产 something

另外,KIF 提到需要将它添加到单元测试目标而不是 UI 测试目标中,因为它用于 UI 测试时可能会有点混淆。

Email main post image The need for more robust systems in the development and testing domain is affected directly by one or more of the following things – the number of applications flooding the app stores, the number of devices running the iOS in the market, and the difficulty in testing these applications (a direct consequence of complexity).

在开发和测试领域对更健壮系统的需求直接受到以下一个或多个因素的影响——应用程序商店涌入的应用程序数量、市场上运行 iOS 的设备数量,以及测试这些应用程序的难度(复杂性的直接后果)。

As in our case today, application and devices metric is so high that manual real device testing cannot be imagined. Thankfully, there are efficient and feature-rich iOS testing frameworks in the market that make iOS application testing faster, easier, and sometimes without demanding any resources from us 😃

就像我们今天的情况一样,应用程序和设备的度量是如此之高,以至于人工真实的设备测试是无法想象的。值得庆幸的是,市场上有高效且功能丰富的 iOS 测试框架,使得 iOS 应用程序测试更快、更容易,有时甚至不需要我们提供任何资源

In this post, we will see 8 frameworks that are helping testers all over the world deliver high-quality iOS applications to their users.

在这篇文章中,我们将看到8个框架,它们帮助世界各地的测试人员向用户交付高质量的 iOS 应用程序。

Table of Contents – iOS Testing Frameworks – A Complete Guide 目录-iOS 测试框架-完整指南 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? What are iOS testing frameworks? 什么是 iOS 测试框架? Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 Top iOS testing frameworks 顶级 iOS 测试框架 Appium TestProject EarlGrey XCTest / XCUITest XCTest/XCUITest Detox 排毒 Calabash 葫芦 OCMock KIF iOS testing frameworks at a glance 测试框架一目了然 Conclusion 总结 Do we really need iOS testing frameworks? 我们真的需要 iOS 测试框架吗? In 2016, Apple sold its billionth mobile phone (iPhone) in the market. By January 2019, 900 million people were actively using iPhones in their daily lives. Two years later, that number became 1.65 billion. That’s huge! And this number is only increasing year after year.

2016年,苹果在市场上销售了第10亿部手机(iPhone)。到2019年1月,9亿人在日常生活中积极使用 iphone。两年后,这个数字变成了16.5亿。这是巨大的!而且这个数字还在年复一年地增长。

On top of it, The numbers are only for iPhones. iOS running devices also include iPads (before iPadOS), and there are more than 500 million floating in the market. These devices are unique in every way I can imagine. Their specifications are different, processor power is different, they even don’t have the same screen size which can be a major problem while running the iOS applications.

最重要的是,这些数字只适用于 iphone。iOS 运行设备还包括 ipad (在苹果公司 ipad 之前) ,目前市场上有超过5亿台。这些设备在任何方面都是独一无二的,我可以想象。它们的规格不同,处理器能力也不同,它们甚至没有相同的屏幕大小,这可能是运行 iOS 应用程序时的一个主要问题。

Going ahead manually to test the iOS application can waste a lot of time, as each of the devices will present its own challenges, and coping with everything including the APIs will just delay everything repeatedly ⏳

手动测试 iOS 应用程序会浪费很多时间,因为每个设备都会有自己的挑战,而处理包括 api 在内的所有事情只会反复延迟所有事情

The solution to this huge fragmentation is iOS testing frameworks, which are designed specifically to be incoherent to the iOS code and facilitate testing on these devices.

解决这种巨大分裂的方法是 iOS 测试框架,这些框架被特别设计成与 iOS 代码不一致,并且便于在这些设备上进行测试。

What are iOS testing frameworks? 什么是 iOS 测试框架? A testing framework is a tool to help you conduct test executions efficiently. As a subset, an iOS testing framework is a testing framework developed especially for iOS mobile application testing 📲

测试框架是帮助您有效执行测试的工具。作为一个子集,iOS 测试框架是一个专门为 iOS 移动应用程序测试开发的测试框架

iOS testing frameworks also provide additional features in a single place such as using Apple’s API, analyzing the test targets, collaborating with other testers, generating screenshots, organizing project files, and generating extensive detailed reports which are not possible during manual testing. The features and highlights of various iOS testing frameworks will enlighten you more in the later sections.

测试框架也在一个地方提供了额外的功能,比如使用苹果的 API,分析测试目标,与其他测试人员合作,生成屏幕截图,组织项目文件,生成手工测试中不可能生成的大量详细报告。各种 iOS 测试框架的特性和亮点将在后面的部分给你更多启发。

Importance of using iOS testing frameworks 使用 iOS 测试框架的重要性 So, what if I say that I am ready to test my iOS application manually without any help? What parameters am I not considering?

那么,如果我说我已经准备好在没有任何帮助的情况下手动测试我的 iOS 应用程序,又会怎样呢?我没有考虑哪些参数?

Expense 开支: iPhones are already priced on the upper bar of the mobile market average. Purchasing all the target devices or taking them on the lease would be a huge expense and can eat up a significant amount of your funds if you are an individual or a small team startup. : iphone 的价格已经处于移动市场平均水平的上限。如果你是个人或者小团队创业公司,那么购买所有的目标设备或者租用它们将是一笔巨大的开销,并且会消耗掉你大量的资金 Time wastage 浪费时间: Personally, I have always felt that : 就我个人而言,我一直觉得automation testing of iOS iOS 的自动化测试 applications always saves my time. The frameworks help in test creation and remind me of the test guidelines and rules to follow, provide ready-made snippets, and even correct a few things (such as URL encoding) behind the scenes. 申请表总能节省我的时间。这些框架帮助创建测试,提醒我遵循测试指南和规则,提供现成的代码片段,甚至在后台修正一些事情(比如 URL 编码) Maintenance overhead 维修费用: Maintenance of an application is always something we need to ponder beforehand during the first release. Applications need to be updated, modified, and sometimes redesigned completely based on newer technologies and frameworks. All these things will require changing scripts and constructing newer ones. Maintenance overhead can be reduced to a large extent if the tester goes for frameworks. : 应用程序的维护一直是我们在第一个版本发布之前需要考虑的问题。应用程序需要根据新的技术和框架进行更新、修改,有时还需要重新设计。所有这些都需要修改脚本并构建更新的脚本。如果测试人员选择框架,维护开销可以大大减少 Analytics 分析: Using a framework brings out detailed analytics with respect to the tests you are performing. These analytics are very important and helpful in determining the test quality of the process. For example, bringing out the test coverage metric can help us understand how much code we are considering in testing. If it’s too low, the test quality is poor and we can work on it. : 使用一个框架可以对您正在执行的测试进行详细的分析。这些分析对于确定过程的测试质量是非常重要和有帮助的。例如,引入测试覆盖度量可以帮助我们理解在测试中需要考虑多少代码。如果它太低,测试质量就很差,我们可以改进它 Resource utilization 资源利用: Using a manual approach requires us to install everything on our personal machine. Along with testing software, our personal machine also runs other programs, and therefore resource management becomes another hectic task. iOS testing frameworks take little space and set up everything on their own, which is the best choice for resource management at a very low cost. : 使用手动方法要求我们把所有东西都安装到我们的个人机器上。随着测试软件,我们的个人机器也运行其他程序,因此资源管理成为另一个忙碌的任务。测试框架占用的空间很小,可以自己设置所有东西,这是资源管理的最佳选择,而且成本非常低 Now that we are convinced about using the iOS testing frameworks in our next iOS project, let’s look at the different options we have 🔍

现在我们已经确定在下一个 iOS 项目中使用 iOS 测试框架,让我们来看看我们有哪些不同的选择

Top iOS testing frameworks 顶级 iOS 测试框架 The following section details the top iOS testing frameworks that are popular among iOS testers currently:

以下部分详细介绍了目前在 iOS 测试人员中流行的顶级 iOS 测试框架:

Appium Appium is an extremely popular open source test automation framework among the testing community. The part reason could be its versatility with programming languages and the ability to test iOS as well as Android and mobile web applications 🌐

是一个在测试社区中非常流行的开源自动化测试框架。部分原因可能是它具有编程语言的多功能性,以及测试 iOS、 Android 和移动网络应用程序的能力

As Appium’s official website mentions, “Appium is built on an idea that testing native apps should not require installing SDK”. With Appium, the user gets full flexibility with the tools and framework in which a tester is proficient and confident.

正如 Appium 的官方网站提到的,“ Appium 建立在一个想法上,即测试本地应用程序不应该需要安装 SDK”。使用 Appium,用户可以充分灵活地使用测试人员熟练和自信的工具和框架。

iOS testing in Appium is performed using JSONWireProtocol and Selenium WebDriver. For all the Selenium fans, it becomes extremely easy to test an iOS app using Appium.

在 Appium 的 iOS 测试使用 JSONWireProtocol 和 Selenium WebDriver。对于所有的 Selenium 粉丝来说,使用 Appium 测试 iOS 应用程序变得非常容易。

Appium Pros

优点

Flexibility in choosing the framework of your choice. 选择框架的灵活性 Since WebDriver is used, Appium supports a long list of programming languages. 由于使用了 WebDriver,Appium 支持很多编程语言 Open source framework and hence boasts a large community. 开源框架,因此拥有一个庞大的社区 Works with native apps on Android, iOS as well as mobile web testing. 适用于安卓、 iOS 和移动网络测试的本地应用程序 Similar APIs can be used for automation tests for both the major platforms – Android and iOS. 类似的 api 可以用于 Android 和 iOS 这两个主要平台的自动化测试 Installing other heavy tools is not required while working with Appium. 使用 Appium 时不需要安装其他重型工具 Recompilation of the application code is not required in Appium. 在 Appium,无须重新编译应用程式码 Appium can work along with emulators, simulators, or real devices. Appium 可以与模拟器、模拟器或真实设备一起工作 Brings a good integration facility with CI/CD tools. 带来了与 CI/CD 工具良好的集成设施 Cons

缺点

The capability to locate images on an iOS mobile application is not supported. 不支持在 iOS 移动应用程序上定位图像的功能 Open source components installed in Appium should have compatible versions with each other. 在 Appium 安装的开源组件应该有相互兼容的版本 Testers often get confused while configuring Appium on their systems. 测试人员在系统上配置 Appium 时经常会感到困惑 Appium execution while working with iOS devices is very slow and can be annoying for the testers. 在使用 iOS 设备时,Appium 的执行非常缓慢,可能会让测试人员感到烦恼 Code example:

代码示例:

text_field = driver. 文本字段 = 驱动程序find_element_by_id 通过 id 查找元素('TextField1' ‘ TextField1’) assert text_field. 断言文本字段get_attribute 属性('value' 价值) is None 没有 text_field. 文本字段send_keys 发送钥匙('Hello World!' 你好世界) assert 断言'Hello World!' 你好世界 == text_field. = text/fieldget_attribute 属性('value' 价值) Bottom line

底线

Appium is a great software and is popular in the community. It has been used for quite a while now and enjoys good support. It is open source and can perform the majority of the tasks required as a tester.

Appium 是一个很好的软件,在社区中很受欢迎。它已经使用了相当长的时间,并且得到了很好的支持。它是开源的,作为一个测试人员,它可以执行大多数需要的任务。

Appium however fails to satisfy those people who need things to move faster and don’t want to get stuck in configuring, setting up or managing components. It can also slow down testing when the device matrix is large.

然而,Appium 并不能满足那些需要快速移动的人,他们不想在配置、设置或管理组件上陷入困境。当设备矩阵较大时,它还可以减慢测试速度。

TestProject TestProject iOS testing framework is based on Appium (as well as Selenium), and is pretty much a framework for everyone (even for Android, Web and API testing). Whether you want a specific operating system or don’t want to use XCode, TestProject has got you covered with a simple test framework with just two pre-requisites: TestProject agent and an Apple developer account for physical devices, or macOS and Xcode for Simulators 🥇

TestProject iOS 测试框架基于 Appium (以及 Selenium) ,基本上是一个适用于所有人的框架(甚至适用于 Android、 Web 和 API 测试)。不管您是想要一个特定的操作系统还是不想使用 XCode,TestProject 已经为您提供了一个简单的测试框架,只有两个先决条件: 物理设备的 TestProject 代理和 Apple 开发人员帐户,或者模拟器的 macOS 和 XCode

TestProject logo Pros

优点

Easier to learn and quicker to execute tests. 更容易学习和更快地执行测试 Comes with iOS devices and iOS simulator support. 支持 iOS 设备和 iOS 模拟器 Requires minimum configurational setup so things can start quickly. 需要最小的配置设置,以便事情可以迅速开始 Includes TestProject recorder equipped with element locator and AI technology for efficient testing. 包括配备有元素定位器和 AI 技术的 TestProject 记录器,用于高效的测试 The operating system is independent and can be run on Windows operating system too. 操作系统是独立的,也可以在 Windows 操作系统上运行 Automation is supported within XCode simulators on MacOS. MacOS 上的 XCode 模拟器支持自动化 Supports all popular programming languages with open source SDK for- Python, Java, JavaScript & C# 支持所有流行的编程语言与开源 SDK for-Python,Java,JavaScript & c # Cons

缺点

Documentation is sometimes released late. A tester might need to go explore the tool himself or reach out to their customer support. 文档有时发布得比较晚。测试人员可能需要亲自去探索这个工具,或者去寻求他们的客户支持 When it comes to developing addons it requires coding skills and if you have none it might be challenging. 说到开发插件,它需要编码技能,如果你没有,这可能是一个挑战 Bottom line

底线

TestProject is an awesome free framework and has garnered positive reviews from all around the world. It is easy to understand and takes no time in setting up the configurations.

TestProject 是一个非常棒的免费框架,获得了来自世界各地的积极评价。这是很容易理解,并不需要时间设置的配置。

The best TestProject advantage is that it does not force the testers to use any specific platform or language. If you are interested in writing the code yourself, it supports all popular programming languages- Python, Java, JavaScript & C#. The flexibility of the framework makes it a must-try iOS testing framework.

TestProject 最大的优点是它不会强迫测试人员使用任何特定的平台或语言。如果您有兴趣自己编写代码,它支持所有流行的编程语言—— Python、 Java、 JavaScript & c # 。该框架的灵活性使其成为一个必须尝试的 iOS 测试框架。

EarlGrey EarlGrey is an open source iOS testing framework developed by Google to test their native iOS applications which include YouTube, Google Calendar, etc 🍵 EarlGrey 1.0 is now officially deprecated and version 2.0 is recommended for the iOS testers.

是一个开源的 iOS 测试框架,由谷歌开发,用来测试他们的本地 iOS 应用程序,包括 YouTube,Google Calendar 等 EarlGrey 1.0现在已经被正式否决,推荐 iOS 测试人员使用2.0版本。

With EarlGrey 2.0, the testers can combine their EarlGrey tests with XCUITest which is Apple’s official testing framework. Also, as stated in Google’s official documentation, “EarlGrey 2.0 uses UI testing target and not unit testing as a target like in EarlGrey 1.0”.

使用 EarlGrey 2.0,测试人员可以将他们的 EarlGrey 测试与 XCUITest 结合起来,XCUITest 是苹果的官方测试框架。此外,正如谷歌的官方文档所述,“ EarlGrey 2.0使用 UI 测试目标,而不是像 EarlGrey 1.0那样将单元测试作为目标。”。

EarlGrey Pros

优点

EarlGrey’s synchronization features are excellent and can synchronize automatically with the network and UI components. EarlGrey 的同步特性非常优秀,可以自动与网络和 UI 组件同步 The testers can also set their own timing if required. 如果需要,测试人员还可以设置自己的计时 EarlGrey improves the test’s stability as the actions are performed after the UI settles into a steady state. EarlGrey 提高了测试的稳定性,因为操作是在 UI 进入稳定状态后执行的 EarlGrey’s tests can be run directly from XCode or through the command line. EarlGrey 的测试可以直接从 XCode 或通过命令行运行 Open source in nature. 自然界中的开源 Cons

缺点

May require additional coding in the application to support some of the APIs. 可能需要在应用程序中进行额外的编码,以支持某些 api Google fetches the tests executions and other test analytics from the testers. This can be turned off but not all of the testers are aware of it. 从测试人员那里获取测试执行和其他测试分析。这可以关闭,但并不是所有的测试人员都知道它 Code example

代码示例

var firstMatch = 1.1true 真的 let matches: MatchesBlock = 2.1.1.1{ (element: AnyObject! 元素: AnyObject) -> Bool 女名女子名in 在 if 如果 firstMatch { firstMatch = 第一匹配 =false 虚假的 return 返回 true 真的 } return 返回 false 虚假的 } Source: EarlGrey examples from the official repo.

来源: 官方回购的 EarlGrey 案例。

Bottom line

底线

EarlGrey is a great testing framework for iOS applications. However, EarlGrey does blend very easily with Google applications and not so easily with other native applications. It has a shallow learning curve and its strength comes from its mingling powers with UI test elements, XCode and XCUITest.

是一个很好的 iOS 应用测试框架。然而,EarlGrey 非常容易与 Google 应用程序融合,而与其他本地应用程序融合则不那么容易。它的学习曲线很浅,它的优势来自于它与 UI 测试元素 XCode 和 XCUITest 的混合能力。

XCTest / XCUITest XCTest/XCUITest XCTest is Apple’s iOS testing framework that’s fully compatible with XCode (and is released in parallel to XCode). XCTest is very versatile and can perform tests on various levels such as unit tests, performance tests and user interface tests ✅ XCUITest can be considered as a sub-class of XCTest and works specifically towards the user interface of the application.

XCTest 是苹果的 iOS 测试框架,与 XCode 完全兼容(并与 XCode 并行发布)。XCTest 非常通用,可以在各种级别上执行测试,例如单元测试、性能测试和用户界面测试。

XCTest / XCUITest Pros

优点

XCTest provides a single solution to a variety of tests. XCTest 为各种测试提供了单一的解决方案 For iOS app developers, the testing becomes very easy due to the same language. 对于 iOS 应用程序开发者来说,由于使用相同的语言,测试变得非常容易 The test execution is faster than other iOS testing frameworks. 测试执行比其他 iOS 测试框架更快 XCTest has a shallow learning curve and can be grasped easily given that the tester is familiar with Objective-C/Swift. 由于测试人员熟悉 Objective-C/Swift,因此 XCTest 的学习曲线较浅,易于掌握 XCUITest provides UI recording capabilities and generating code out from it. XCUITest 提供 UI 记录功能,并从中生成代码 Easier to deal with CI/CD tools and get seamless integration. 更容易处理 CI/CD 工具并实现无缝集成 Cons

缺点

Limited language support. Unfamiliar testers might have to go through a learning phase which can take time. 有限的语言支持。不熟悉的测试人员可能要经历一个需要时间的学习阶段 XCTest/XCUITest does not have cross-platform support. XCTest/XCUITest 没有跨平台支持 Only technical testers with a programming background can perform testing on XCTest. 只有具有编程背景的技术测试人员才能在 XCTest 上执行测试 Deeplinking is not supported by XCTest/XCUITest. XCTest/XCUITest 不支持深度跳转 Code example

代码示例

class TableValidationTests: XCTestCase 类 TableValidationTests: XCTestCase{ /// Tests that a new table instance has zero rows and columns. //测试新表实例是否具有零行和零列 func 真菌testEmptyTableRowAndColumnCount 和 columncount() { let table = 让表 =Table 表() XCTAssertEqual(table. 表rowCount, 0, "Row count was not zero." “行数不是零。”) XCTAssertEqual(table. 表columnCount 柱状数, 0, "Column count was not zero." ”列计数不为零。”) } } Source: Official XCTest documentation

来源: 官方 XCTest 文档

Bottom line

底线

XCTest/XCUITest is similar to what everything has been with Apple. It is a closed iOS testing framework with programming limitations. This is a great disadvantage with people familiar with testing iOS apps on cross-platform frameworks with the language of their choice. Honestly, XCTest is perfect for those who have developed iOS applications and work with XCode for their development purposes.

XCTest/XCUITest 类似于苹果的所有功能。它是一个封闭的 iOS 测试框架,有编程方面的限制。对于那些熟悉在跨平台框架上用自己选择的语言测试 iOS 应用程序的人来说,这是一个很大的缺点。老实说,XCTest 非常适合那些开发 iOS 应用程序和使用 XCode 进行开发的人。

Detox 排毒 Detox is an end-to-end testing tool that uses gray box testing to control the flakiness and unpredictable behavior of black-box testing tools such as Appium 🤖

Detox 是一个端到端的测试工具,它使用灰盒测试来控制像 Appium 这样的黑盒测试工具的片状和不可预测的行为

Detox comes with two very strong USPs. First, it can test an application while it is running on the simulator and therefore works as if a real user is finding the defects. Second, Detox is Javascript based and therefore you can run anything that supports it.

排毒有两个很强的毒副作用。首先,它可以在应用程序在模拟器上运行时对其进行测试,因此就像真正的用户正在发现缺陷一样工作。其次,Detox 是基于 Javascript 的,因此你可以运行任何支持它的东西。

Detox Pros

优点

Detox comes with cross-platform support. 排毒带有跨平台的支持 Can test an application just like a real user. 可以像真正的用户一样测试应用程序 Advanced monitoring reduces the flakiness of the tool. 先进的监控减少了工具的脆弱性 Very high and smooth support for continuous integration tools. 对持续集成工具的高度和流畅的支持 Does not depend on Webdriver for testing support. 不依赖于 Webdriver 的测试支持 Uses very simple and easy-to-use APIs written in Javascript. 使用用 Javascript 编写的非常简单易用的 api Open source with a lot of contributions since its inception. 开放源码,从一开始就有很多贡献 Cons

缺点

Testing on real iOS devices is still not supported. 在真正的 iOS 设备上测试仍然不被支持 Code example

代码示例

describe 描述('Login flow' 登录流程, () => {
it 它('should login successfully' 应该成功登录, async 异步的 () => { await device. 等待装置reloadReactNative();
await 等待element 元素(by. 通过id 身份证('email' ‘ em ail’)).typeText('john@example.com'); await 等待element 元素(by. 通过id 身份证('password' 密码)).typeText('123456' 123456); await 等待element 元素(by. 通过text 文本('Login' “登录”)).tap 踢踏舞();
await 等待expect 期待(element 元素(by. 通过text 文本('Welcome' 欢迎))).toBeVisible(); await 等待expect 期待(element 元素(by. 通过id 身份证('email' ‘ em ail’))).toNotExist(); });
}); Source: Official Detox Repo

来源: 官方排毒回收站

Bottom line: Detox brings important things to the table. It is gray box testing and performs end-to-end testing using Javascript which is one of the most popular languages in the world today. So, thumbs up for that! The only problem I find with Detox is that it does not support iOS real device testing and uses a simulator to achieve the same.

底线: 排毒可以把重要的事情摆到桌面上。它是灰盒测试,并使用 Javascript (当今世界最流行的语言之一)执行端到端测试。所以,竖起大拇指吧!我发现 Detox 唯一的问题是它不支持 iOS 真实设备测试,并且使用模拟器来实现同样的功能。

Using a simulator is also good but cannot check the quality of the application better than a real device. Therefore, I think this factor can be a deal-breaker for many testers.

使用模拟器也不错,但不能检查应用程序的质量比一个真正的设备更好。因此,我认为这个因素对于许多测试人员来说都是一个阻碍因素。

Calabash 葫芦 Calabash is a big name among the iOS testing frameworks listings and communities because of its stability and approach towards the construction of the tests. Calabash uses Cucumber, which enables non-tech people to constructs tests easily 💫 Calabash comes with a long list of language support and can run on iOS as well as Android applications.

Calabash 在 iOS 测试框架清单和社区中很有名气,因为它的稳定性和测试构建的方法。Calabash 使用 Cucumber,它使非技术人员能够轻松构造测试。 Calabash 提供了一长串语言支持,可以在 iOS 和 Android 应用程序上运行。

Calabash Pros

优点

Open source and one of the major iOS testing frameworks in focus. Hence, continuous development. 开源和一个主要的 iOS 测试框架,因此,持续开发 Supports Python, C#, PHP, Ruby, Perl, and many more. 支持 Python,c # ,PHP,Ruby,Perl 等等 Constructs tests with the BDD approach which is extremely helpful for non-tech people. 使用 BDD 方法构建测试,这对非技术人员非常有帮助 It’s a cross-platform testing framework and hence enables tests across platforms without creating newer ones. 它是一个跨平台的测试框架,因此支持跨平台的测试,而不需要创建更新的测试 Supports iOS emulators as well as physical devices. 支持 iOS 模拟器和物理设备 Calabash is known to be a very stable iOS testing framework. 众所周知葫芦是一个非常稳定的 iOS 测试框架 Cons

缺点

Calabash requires coding outside its BDD bubble. 葫芦需要在它的 BDD 气泡之外进行编码 Takes time to run the application. 运行应用程序需要时间 Does not have a very large community to help. 没有很大的社区可以帮助 Code example

代码示例

Scenario: Money Transfer Changes Balance 情景: 资金转移改变余额in 在 Wallet 钱包 Given that I have $ 假设我有 $100 in 在 my wallet 我的钱包 And I add $ 然后我加上 $200 to my wallet 我的钱包 My wallet balance increases to $ 我的钱包余额增加到 $300 Bottom line

底线

Calabash has gained a lot of popularity, and the main reason behind this is the support for the BDD approach.

葫芦已经获得了大量的普及,这背后的主要原因是对 BDD 方法的支持。

BDD is always preferred by people as it can get the task done without learning the programming languages and creating complex logic in it. But people with programming backgrounds often criticize Calabash for the same reason. Calabash also does not have a large community compared to Appium.

BDD 总是受到人们的青睐,因为它可以在不学习编程语言和创建复杂逻辑的情况下完成任务。但是有编程背景的人经常出于同样的原因批评 Calabash。与 Appium 相比,卡拉巴什也没有一个大的社区。

OCMock OCMock is an open source project enhancing the iOS testing methods by creating mock objects. OCMock stands for Objective-C Mock which means that the tester can create the mock objects using Objective-C language 👩‍💻

是一个开源项目,通过创建模拟对象来增强 iOS 测试方法。OCMock 代表 Objective-C Mock,这意味着测试人员可以使用 Objective-C 语言创建模拟对象

OCMock is actively developed and includes three types of mocks – stubs, dynamic mocks, and partial mocks. The examples and definitions can be learned at the OCMock official website.

正在积极开发 OCMock,它包括三种类型的模拟—— stub、动态模拟和部分模拟。这些例子和定义可以在 OCMock 官方网站上学习。

OCMock Pros

优点

Easy learning curve and easy to create objects of various types. 简单的学习曲线,易于创建各种类型的对象 Extensive documentation to help the testers. 大量的文档来帮助测试人员 iOS app development and OCMock both use Objective-C and therefore it becomes easier to work with OCMock. iOS 应用程序开发和 OCMock 都使用 Objective-C,因此使用 OCMock 更加容易 It’s an open source framework and therefore sees an active development from people all around the world. 它是一个开源框架,因此看到了来自世界各地人们的积极发展 Cons

缺点

Just to mock objects. Does not provide a complete iOS testing solution. 不提供完整的 iOS 测试解决方案 Code example

代码示例

id userDefaultsMock = 4. id/userDefaultsMock =OCMClassMock([NSUserDefaults class 类]); // set it up to return a specific value when stringForKey: is called //将其设置为在调用 stringForKey: 时返回特定的值 OCMStub([userDefaultsMock stringForKey:@ 1. userDefaultsMock stringForKey:@"MyAppURLKey" “我的苹果钥匙”]).andReturn 和 return(@"http://testurl" “ http://testurl”); // set it up to return the specified value no matter how the method is invoked //将其设置为返回指定的值,无论如何调用该方法 OCMStub([userDefaultsMock stringForKey:[OCMArg any 奥克马格尼]]).andReturn 和 return(@"http://testurl" “ http://testurl”); Source: Official OCMock Documentation

来源: 官方 OCMock 文档

Bottom Line

底线

OCMock is not a testing framework but works with many. In its documentation, OCMock does not mention anywhere about being a “testing framework” or “testing solution”. Although, OCMock does mention enhancing the abilities of XCTest and other such frameworks that support it.

不是一个测试框架,但是可以与许多测试框架一起工作。在其文档中,OCMock 没有提到它是一个“测试框架”或“测试解决方案”。尽管如此,OCMock 确实提到了增强 XCTest 和其他支持它的框架的能力。

So, if you are someone who already knows an iOS testing framework and wants to enhance it by adding OCMock, it is actually a great choice and helps a lot in creating mock objects. But if you are expecting a complete testing solution with OCMock, you will be disappointed.

所以,如果你已经知道一个 iOS 测试框架,并且想通过添加 OCMock 来增强它,那么它实际上是一个很好的选择,并且在创建模拟对象方面很有帮助。但是,如果您期望使用 OCMock 获得一个完整的测试解决方案,那么您将会失望。

KIF KIF is an integration testing framework designed for iOS applications. KIF stands for “keep it functional” and is used for UI testing on an iOS application. KIF uses the XCTest target to build the automation tests. Although, it does use undocumented APIs and therefore should never be used in production ❌

KIF 是为 iOS 应用程序设计的集成测试框架。KIF 代表“保持功能性”,用于 iOS 应用程序上的 UI 测试。KIF 使用 XCTest 目标来构建自动化测试。尽管如此,它确实使用了未登记的原料药,因此绝不应该用于生产 something

Also, KIF mentions that it needs to be added to the unit testing target and not the UI testing target which can be a bit confusing as it is used for UI testing.

另外,KIF 提到需要将它添加到单元测试目标而不是 UI 测试目标中,因为它用于 UI 测试时可能会有点混淆。

KIF Pros

优点

Objective-C support and therefore becomes easy for the developers. 支持 Objective-C,因此对开发人员来说很容易 KIF testing is somewhat similar to mimicking a user’s actions which is helpful. KIF 测试在某种程度上类似于模仿用户的行为,这是有帮助的 KIF does not require an additional configurational setup. KIF 不需要额外的配置设置 XCTest advantage gives it the upper edge towards easy integration with the XCode tools. XCTest 的优势使它具有与 XCode 工具易于集成的优势 KIFs tests are noted to be faster and quicker. 知识密集型基金测试被认为是更快更快的 Cons

缺点

Language constraint as only Objective-C is used in testing. 语言约束作为唯一的 Objective-C 用于测试 KIF does not enjoy great support as of now. 到目前为止,KIF 没有得到很大的支持 KIF does not support popular frameworks such as Cucumber for which it has been criticized. KIF 不支持受到批评的流行框架,如 Cucumber 测试框架一目了然

这是一个很长的列表,我敢肯定回忆所有的要点会很困难在下面的部分中,我已经将这些 iOS 测试框架组织成表格形式,让你在一个表格中比较所有的东西:

https://blog.testproject.io/wp-content/uploads/2021/08/A-Complete-Guide-to-iOS-Testing-Frameworks.png

总结 自动化测试已经开始主导测试市场,因为它几乎没有错误率和更快的测试执行能力。但总的来说,自动化只是一个更广泛的保护伞,它涵盖了许多框架,这些框架有自己的特性、优点,以及显而易见的薄弱环节。

尽管如此,我相信软件的弱点不是一般性的,而是针对特定的用户。如果我的自动化测试人员非常精通 Objective-C,我可以很高兴地选择一个支持 Objective-C 的 iOS 测试框架(即使它是唯一支持的语言!).

在这篇文章中,我们试图将这些差异分离出来,并将测试者的舒适程度牢记在心。例如,一个支持五种语言的框架比一个支持两种语言的框架涵盖了更多的测试人员。我希望这些差异将帮助您根据您的喜好和要求选择最佳的工具。

author

石头 磊哥 seven 随便叫

company

HSBC

大家好,本人不才已经离开了thoughtworks,加入了HSBC,目前全职automation test leader,兴趣爱好前端,之前是thoughtworks 西安QA社区的leader,如果有兴趣分享话题,或者想加入tw,HSBC,可以找我

roles

QA(营生) dev(front-end dev 兴趣爱好)

联系方式

如果想转载或者高薪挖我 请直接联系我 哈哈

wechat:

qileiwangnan

email:

qileilove@gmail.com