OSSとして公開された、巨大なFacebookのiOSアプリでUIAutomationを使うために使われているツール群

iOSアプリ開発、動作確認、テストを経験されている方なら分かるとおもいます。UIを確認したいときのiOSアプリの動作確認を自動化する時、UIAutomationを使う形が多いですね。そして、その場合において、一番のボトルネックはやはり実機やSimulatorの同時起動、実施速度の制約になっていきますよね。

UIAutomationは、実機で実施するには遅延があります。また、実機ではデータをCleanにして毎回テストを回すには、それ用のdebug機能を実装しなければ不可能です。

遅延に対しては、Facebookのinstruments-without-delayを経由して、遅延の少ないSimulatorで実施するこができていました。そして、特定のディレクトリを削除して毎回Cleanな状態を確保できていました。そういうことができるiOS Simulatorの価値は高いものです。(Xcode7ではツールの制約上この機能が正常に動作しませんが、このGistによると、Simulatorのplistをinjectionすれば有効にもできるそうな。)

例えば、Appiumはこのツールを組み込んでいるので、iOS実機もそうですが、シミュレータではより早く安定したGUI Testigを実施することができます。

なのですが、Simulatorは1つのセッションしか、Mac上では起動することができません。これはSimulatorやXcodeのinstrumentsに課せられた制約になります。

そこで、最近Facebookが以下の通りその問題を解決するようなライブラリをOSSとして公開しました。

FBSimulatorControl

Objective-Cにより実装されていて、複数シミュレータを起動することができるようにしているもののようです。

以下がこのOSSのAboutなのですが、このライブラリは、Private APIの DVTFoundationCoreSimulator にリンクして、直接ごにょごにょしているらしいです。例えば、シミュレータを直接操作する simctl を操作したり。Private APIをモリモリ使っているぽいので、Xcodeの変更に対してリスクはありますが、それでもFacebook同様、巨大なアプリはこういう形のツールを使わなければ、GUI Testingでは結構な時間を持っていかれますよね…

About

The original use-case for FBSimulatorControl was to boot Simulators to run End-to-End tests with WebDriverAgent. As FBSimulatorControl is a Mac OS X framework, it can be linked to from inside any Mac OS Library, Application, or xctest target. There may be additional use-cases that you may find beyond UI Test Automation.
FBSimulatorControl works by linking with the private DVTFoundation, CoreSimulator and DVTiPhoneSimulatorRemoteClient frameworks that are present inside the Xcode bundle. Doing this allows FBSimulatorControl to talk directly to the same APIs that Xcode and simctl do. This, combined with launching the Simulator binaries directly, means that multiple Simulators can be launched simultaneously. Test targets can be made that don’t depend on any Application targets, or that launch multiple Application targets. This enables running against pre-built and archived Application binaries, rather than a binary that is built by a Test Target.

また、彼らは同時期にWebDriverAgentも公開しました。これは、UIAutomation.freamwork をAppleが公開しているJavaScriptライブラリを介さず直接操作し、さらにはWebDriverのAgentとして操作を与えることをできるようにしたものです。

How it works

WebDriverAgent works under-the-hood by linking to UIAutomation.framework and calling the same APIs that are exposed through Apple’s UIAutomation.js framework.
Because it is not tied to an Instruments run, it is able to run across applications or even on the home screen. Furthermore, it’s much faster than any JavaScript UIAutomation.js driver as it runs a native HTTP server and does not need to ferry commands and results through a makeshift run loop.

AppiumはUIAutomation.jsを経由している。一方で、これはPrivateHeaderを直接取得して、その中からUIAutomaton.frameworkを直接操作してる。そのため、Javascriptのフレームワークより高速なのですね。KIFに近いかな。Appiumよりも安定していそうな感じ。

XCUITestが普通になると、WebDriverAgentはそこまで必要でなくなるかなー。という感じ。ただ、まだ先のことでしょう…
このOSS群も、必要な組織はごく一部の大きなiOSアプリを開発しているところに限られるのでしょうが…

1 Comment

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.