[Appium] Progressive Web Apps on iOS

Progressive Web Apps (PWA) works as an app on iOS while the base is Web Site. Appium allows you to automate, but it needs a few tricks. Establish a session with 1) autoLaunch: false and bundleId: ‘com.apple.mobilesafari’, or 2) without app and bundleId but with includeSafariInWebviews: true Launch the home screen with activating com.apple.springboard Click…More

[Android] A tip to automate push notification on Android via adb

This tip is not new. I implemented this maybe around five years ago. In general, push notification related feature is difficult to automate since it requires external service. We must send a request to push notification server and should wait for the notification. If we focused on Android Application, we could make this kind of…More

A couple of days ago, I had a conversation about Android tests on Twitter. I would leave it here a note. The conversation was: How to run UI tests in order Is there any good way to make them stable? How to get a system dialogue via Espresso? We discussed: It’s better to use RuleChain…More

[Flutter]Tests strategy in Flutter

I read the documentation of Flutter 1.0 based. I also tried to run each test type explained by the documentation. Flutter has three type testing feature. When I saw the page and below a table, I remember my opinion for mobile test automation like 1 or 2. The flutter also has a similar role for each…More

[Android]Androidテスト全書は是非手にとって読んでほしい1冊

Androidテスト全書が発売されましたね! とてもめでたい。 私はアーリーアクセスの段階で野次馬のようにいくつかコメントさせていただいたりしました。また、推薦コメントとしてトップにも記載していただいて、大変ありがとうございます。 個人的には、このような書籍が私の学び始めの頃にあればとても知の高速道路を走れたのでは感が満載のものだと感じます。”テスト”という一言で丸っと全体を包むのではなく、いくつかレイヤーも分けつつ分解しているのもとても良いですよね。様々なレイヤーで目的に合わせながらテストの実行環境が整っていく(であろう)これからの市場ですが、それらを利用するにあたり基礎となるものだと感じています。 なおここでいう”テスト”は、一律、開発者テストやテストエンジニアによりテストコードを書いていくという範囲での話に焦点を当てます。 2, 3章 多くは実装やアーキテクチャに依存することも多い話ですね。この書籍では、巷でみる(最近)よく使われるライブラリを使ったテストの書き方のほか、テストタブルの考え方まで踏み込んだ箇所があります。そのため、単なるツールの使い方ではなく、その必要性や用途などまで学ぶことができるのではないでしょうか。それらはAndroidというものに限らないところも多いので、iOSやそのほかのWeb系の話に流れたとしても、転用のきく知識となるかと思います。 ここはコードも多く出るので、読みながら写経しながら進めることが一番良いと感じています。 4, 5, 6章 UIテストのEspresso, Appiumを使った話。 これら、結構比較構造で紹介される場面も見ますね。同じ”UIテスト”という言葉として。ただ、多少はカバーする分野がかぶってますが、私は全く対立するものではないと思っています。(Appium自体、Espresso/uiautomator2を経由して色々とした操作を実現していますし。) そこらへんも説明されたり、具体的な実装の話まで踏み込まれています。 最近だと AppiumのAIによる要素セレクタを試してみたら、自動テストの未来を感じた でも取り上げられましたが、Appiumをモバイルアプリ操作のフレームワークとしてツール群の間に挟むことで、それよりも上のレイヤで様々な取り組みを実施できるなどもあります。これもEspressoだけを中心とした形式で、test.ai のような企業が独立して取り組むには難しい面もありますね。 Espressoの方がとても良い場面も多くあります。そのため、私は Test automation design for Cookpad’s global Android app というブログを、クックパッドの海外事業部のページに投稿しました。そこでは、EspressoもAppiumも(後者は将来的に、ですが)使う流れを載せています。 適材適所で使おう、という話ですね。個人的な日本・世界での活動をベースにすると、両方を行き来できる人は非常に限られていて、そういう人がいる組織は方針の選択など含めてとても強いのだと感じました。私が見た世界の中では、純粋なAndroid開発者だけしかいない(開発者人数も限られている)ところは大体はEspressoですが、Test/QAエンジニアをもつところは大体はAppiumを利用しているようです。その両方を行き来できる人は選択しているぽいです。ただ、Agodaのように色々と判断を倒しているようなところもいくつかあるようですね。 いずれも、Espressoを使うところは単機能(or 1つのView)における実装の確実さを担保していきたいというモチベーションが大きいように思えます。私たちもそんな感じでした。ユーザのシナリオや、実環境に近しいところを対象にしようとしたらAppiumの比率が高くなるという感じでしょう。HeadSpinのように、物理的にもよりユーザに近しいところのテストを世界各国で実施できる環境では、Appiumの方が多数のようです。 7章 JUnit5の話ですね!私もいくつか触ったことがありますが、まだJUnit5を少なくとも10人以上でガシガシ開発しているような組織にはほいそれと導入はできなかったですが。。(JUnit4 のRuleを使ったものもそれなりに持っているプロジェクトですし) JUnit5のいくつかのアノテーションなどは個人的にも導入して行きたいと思っていたものです。なので、JUnit5が成熟して、Androidの標準ライブラリ周辺でも特に壁なく利用できるところまでいくと良いなと思います。 Jetpackとして丸っとした開発ツールの公式化が進みましたし、その中にJUnit5が入り始めるとガッと世界は進みそうだと感じます。 8章 CI/CD環境はモバイルの場合は特に、最近も頭を抱えますね…CircleCIは鉄板だと思います。OSSでしか触れてはないのですが、最近だと性能改善もだいぶ見られるようですね。 私は、1000件程度のnon-UIテスト、40件行かないくらいのEspressoによるUIテストを実装していたプロジェクトにおいて、lint, 全テストをPush毎に、10分以内で全てを終わらせるためにx3 Speed Up Android CI at Cookpadという構成を取っていました。その結果、多くの場合は6分~7分程度で、テストなど含めて開発のフィードバックサイクルを回せるようにしていました。この書籍でいう、”コミットステージ”でEspressoによるUIテストも含めて完了させていた、という感じです。ただ、その環境はAWS上で動作するJenkin環境でした。 それとは別に、将来的には定期的にUIテストの、ユーザ受け入れレベルのものを実施したいとも思っていました。(が、そこらへんは環境の成熟など含めてまだ手軽ではないですね。。。)これにより、手動テストステージの多くは省ける + パフォーマンス系のあたいもここで取得できる状態には持っていけると思います。 先にも書きましたが、これからは用途に応じたテスト実行環境が成熟していく時期だと思うので、読者の皆様は待っておいてもらえると良さそう。(私はそういうところで少しの間、時間を使うことにしました。) 余談 いくつか私も情報の整理のためにAndroid向けの砂場repository とか、iOS向けの砂場repository…More

[Android] AndroidX for tests and Robolectric4

A couple of days ago, androidx.test libraries were published, finally. https://developer.android.com/training/testing/release-notes Then, Robolectric4 was also published. https://github.com/robolectric/robolectric/releases/tag/robolectric-4.0 The benefit of Robolectric was making android test fast with some mocking Android APIs. Meanwhile, the mocking leaded wrong test results, sometimes. I faced many times such case. According to the release note, Robolectric has also a bunch…More

[Android]Relax “Restrictions on non-SDK interfaces” on Android P

Android P has a feature of Restrictions on non-SDK interfaces. => https://developer.android.com/preview/restrictions-non-sdk-interfaces If you have a method like below, you will face java.lang.NoSuchMethodException: setAnimationScales [class [F] error. This is because of the non-sdk interface feature. https://github.com/KazuCocoa/DroidTestHelper/blob/3781fa40a6c9dfd34e1cb94ae230a98931af3313/droidtesthelperlib/src/main/java/com/kazucocoa/droidtesthelperlib/HandleAnimations.kt#L23 To avoid the error, we can call below adb commands. After this, calling setAnimationScales succeeds. I’ve appended the note…More

[Android]Use PermissionRequester to get permissions

I’m using composer to handle instrumented tests. GrantPermissionRule has introduced for the andorid test support library, [Android]Checking Android Testing Support Library 1.0. The Rule work as @Rule in JUnit4. We’d like to clean screenshots every time. But we need some permissions to clean them. To achieve it, we can use PermissionRequester to get permissions. In…More