iOS 自动化测试 - XCTest 与 Appium

时间:2023-05-02
本文介绍了iOS 自动化测试 - XCTest 与 Appium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在寻找测试工程师和 iOS 开发人员对特定问题的意见.

I am looking for opinions from test engineers and iOS developers regarding a specific matter.

我已经使用 Appium 一年多了,在真实设备上运行移动 Web 测试时遇到了各种困难.每次 Apple 在 XCTest 或 Safari 中进行更改时,Appium 都会受到直接影响(即使他们修复了某些问题,也会出现一些其他问题),并且已经到了我要花更多时间解决 Appium 相关问题的地步与来自 AUT 的相反.

I have been using Appium for over a year now, and I have come across various difficulties while running mobile web tests on real devices. Every time Apple makes changes in XCTest or Safari, Appium is directly impacted (even if they fix something, some other issue pops up in its place), and it has come to a point where I'm spending more time resolving Appium related issues as opposed to the ones from an AUT.

此外,无论如何,您都需要一台 Apple 计算机来开发和执行 Appium iOS 测试.所以我想为什么不直接使用 XCTest 使用 Swift 或 XCTest 支持的任何语言编写测试呢?

Furthermore, you would need an Apple computer to develop and execute Appium iOS tests anyway. So I thought why not use XCTest directly to write tests using Swift or whatever language that XCTest supports?

非常感谢拥有 Appium 和 XCTest(Swift 等)自动化测试经验的人的评论和意见.

I would very much appreciate comments and opinions from people who have experience with both Appium and XCTest (Swift, etc) automated tests.

与 XCTest 相比,使用 Appium 自动化 iOS 原生和 Web 应用程序测试有哪些优势?

What are the advantages of using Appium to automate iOS native and web apps tests over XCTest?

推荐答案

正如您已经发现的那样,Appium 的最大缺点之一是它是一个第三方框架,并且几乎每次 Apple 发布 Xcode 时都会中断.这不太可能改变,因为 Apple 现在维护自己的 UI 测试框架.

As you've already discovered, one of the greatest disadvantages of Appium is that it's a third party framework and it breaks pretty much every time Apple makes an Xcode release. This is unlikely to change since Apple now maintains its own UI testing framework.

使用 Appium 还有其他一些优势 - 您可以从多种语言(Java、Ruby、Python、C#...)中进行选择,这使得任何可以使用其中一种非常流行的语言进行编程的人都可以使用它,并且您可以想象在 iOS 和 Android 上同一应用的测试之间共享代码.

There are some other advantages to using Appium - you can pick from quite a few languages (Java, Ruby, Python, C#...), which makes it accessible to anyone who can program in one of those very popular languages, and you can conceivably share code between tests for the same app on iOS and Android.

根据我的经验,虽然有很多人在使用 Appium,但社区支持水平并不能弥补令人失望的维护水平;除了 Appium 与 Xcode 兼容性的脆弱性之外,我发现一些关键功能在某些绑定中仍未实现,例如在 Python 中滚动.

In my experience, while there are a lot of people out there using Appium, the level of community support doesn't make up for the disappointing level of maintenance; aside from the fragility of Appium's compatibility with Xcode, I've found that some key functions have remained unimplemented in some bindings, e.g. scrolling in Python.

对于 UI 测试,可靠性是框架中最重要的方面.没有可靠性,您就无法信任测试来标记问题,而没有信任,您的测试对您和您的团队几乎没有价值.这就是我推荐 XCTest 而不是任何第三方框架的原因.

With UI tests, reliability is the most important aspect of your framework. Without reliability, you can't trust the tests to flag up problems, and without trust, your tests provide little to no value to you and your team. This is why I recommend XCTest over any third-party framework.

使用 XCTest,您永远不必担心无法更新您的 Xcode 版本,并且该框架按照 Apple 的发布标准进行维护.与所有 iOS UI 测试框架一样,存在一些错误(尤其是在选择器周围),但我发现框架的稳定性和它归 Apple 拥有的事实超​​过了奇怪错误的缺点.

With XCTest, you never have to worry about not being able to update your version of Xcode, and the framework is maintained to Apple's release standards. As with all the iOS UI testing frameworks, there are some bugs, (particularly around pickers) but I find that the stability of the framework and the fact that it's owned by Apple outweighs the disadvantages of the odd bug.

获得 Apple 的认可是使用 XCTest 的重要优势,因为 Apple 可以移除对 Appium 所依赖的 API 的访问权限,而 Appium 可能会在一夜之间永远停止工作.从历史上看,Apple 不会在至少一年通知的情况下简单地取消对自己框架的支持.

Being endorsed by Apple is a significant pro for using XCTest, since Apple could remove access to the APIs which Appium depends on and Appium could stop working forever overnight. Historically, Apple do not simply remove support for their own frameworks without at least a year of notice.

要直接使用 XCTest,您需要使用 Swift(推荐)或 Objective-C.没有 Appium 提供的语言选择那么多,但是对这两种语言的支持是一致的,因为它们都使用相同的实现.Swift 是一种强有力的语言选择,尤其是对于大型项目而言,因为它的类型安全性允许您在运行前发现许多编程错误.这两种语言还在 Xcode 中为您提供了出色的智能感知(自动完成)支持,这是 Python 或 Ruby 等动态"语言无法提供的.

To use XCTest directly, you need to use Swift (recommended) or Objective-C. There isn't as much language choice as Appium gives, but support for both languages is consistent as they both use the same implementation. Swift is a strong choice of language, especially for larger projects, because its type-safety allows you to notice many programming errors before runtime. Both languages also give you great intellisense (autocomplete) support in Xcode, which is something that is not offered out of the box by 'dynamic' languages like Python or Ruby.

随着关于将 XCTest 用于 UI 测试的信息越来越多,并且越来越多的人觉得能够采用它,围绕 XCTest 的社区正在不断壮大.用于 UI 测试的框架的许多部分多年来一直用于单元测试,因此在许多方面,在添加 UI 测试支持之前,已经有很多关于使用它的信息.

The community around XCTest is growing as more information becomes available about using it with UI tests and more people feel able to adopt it. Many parts of the framework used for UI testing have been being used for many years for unit tests, so in many ways, there was already a lot of information available about using it, before the UI testing support was added.

两个框架使用相似的概念 - XCUIApplication 类似于 Appium 的驱动程序,它使您可以访问屏幕上的内容.两个框架提供的功能级别可以说非常相似,因此这取决于您的优先级在哪里 - 可靠性 (XCTest) 或跨其他平台的可重用性和语言可访问性 (Appium).

Both frameworks use similar concepts - XCUIApplication is similar to Appium's Driver, which gives you access to what's on the screen. The level of functionality offered by both frameworks is arguably very similar, so it depends where your priorities lie - with reliability (XCTest) or reusability across other platforms and language accessibility (Appium).

这篇关于iOS 自动化测试 - XCTest 与 Appium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:espresso contrib 中的 openDrawer 已弃用 下一篇:使用仪器和工具对 iOS 应用程序进行 UI 自动化测

相关文章

最新文章