https://github.com/appium/appium/releases/tag/v1.6.0 support XCUITest(WebDriverAgent) to test against Xcode8 x above iOS9.3 BTW, this feature has some unstable/known issues support UI Automator 2 for Android I already tried previous its beta version in my company, and then I issued some problems to Appium and it already fixed. I’ll switch to this new version from previous 1.5 in…More
Tag Archives: android
[Android]Chat Client for Phoenix server
I implemented a chat server and an iOS application and posted about them on [Swift][Elixir]implement chat server and client. Today, I implemented easy an android chat application for the server. https://github.com/KazuCocoa/WebSocketDemoForAndroid Use Toothpick and Smoothie I use libraries called toothpick and smoothie as DI, such as Dagger but they are simpler than it. https://github.com/KazuCocoa/WebSocketDemoForAndroid/commit/24e9d3d8fa3abf8a8e1116b35334ff22d8d81d2e And…More
[Android]Try Espresso Test Recorder
AS2.2 Preview3がリリースされましたね。その中で、個人的に待っていたEspresso Test Recorderが実装されたので試してみました。 https://sites.google.com/a/android.com/tools/recent/androidstudio22preview3available 生成されたコードはこちら。 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters package com.kazucocoa.droidtodo; import android.support.test.espresso.ViewInteraction; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4;…More
[Android]Dive into Toothpick
過去の調査に加えて、Toothpickに潜ってみました。 簡単なまとめ @inject アノテーションが付いている要素を、 scope.getInstance(); したクラスでinjectionして利用することができる。 inject可能な要素は木構造で表現され、親scopeに含まれる要素をinjectしたメソッド/クラスとして利用することができる scope外の要素を使おうとするとクラッシュ bind(IFoo.class).to(Foo.class) で Foo.class を使い回すことができるし、 bind(IFoo.class).to(new Foo()) では都度新しいinstanceを生成して利用可能 ActivityやFragmentといったライフサイクルに対して Toothpick.openScopes(getApplication(), this) してscopeを設定した場合、そのライフサイクルの onDestroy のタイミングでそのscopeをcloseする必要がある Scopeはアノテーションベースでも独自で設定できる 導入 ライブラリとして利用するための導入は こちらのWiki に任せて省略。 例えば、以下のFooクラスに対してinjectしようとします。 この時、scope.getInstance(Foo.class) したら、そのクラス内でこの Foo.class でinjectされている Foo、Bar、setQurtz を @Inject で指定して使い回すことが可能となります。 ついでに bind に関して少し触れておきます。以下のようにbindすると、 それぞれのケースにおいて以下のようになります。 case1 では、すでにFoo.class のインスタンスが存在するならそれを使い、それをIFoo.classに紐付ける case2 では、常に新たな Foo.class のインスタンスを使い、それをIFoo.classに紐付ける Scopeの種類 Scopeの種類としては2つ存在します。 a binding 都度、bindされるたびに新しいインスタンスとして利用される 子要素では親要素を上書き可能 bind(IFoo.class).to(Foo.class); みたいな感じで都度bindされるやつです scoped…More
[Android]ToothpickでTree Based DI
最近、Tree Based DIツールのToothpickを知りました。 https://github.com/stephanenicolas/toothpick このメンテナは、RoboGuiceをメンテしていたGrouponの人です。RoboGuiceの更新を見に行った時にたまたま見つけました。ここ数ヶ月で作り上げられたDIライブラリのようです。このリポジトリWikiのあるページに、AndroidにおけるDIの歴史や経験をまるっと学ぶことができて良かったです。 https://github.com/stephanenicolas/toothpick/wiki/FAQ#why-creating-toothpick- さらには、彼らがRoboguiceからDagger1/2と触れた上でこのToothpickを作るに至った流れも書いています。 まだWikiと簡易サンプルをさっと眺めた程度なのですが、備忘録がてら。 AndroidでToothpick Toothpick自体はJavaのTree Based DIです。これ単体ではAndroidはサポートしていません。Androidをサポートするために、smootheがあります。 このサンプルにあるように、Toothpickはsmoothieを介してAndroidにDIを提供します。 幾つかのDIツールとの速度比較 Roboguice4/Dagger1/Dagger2/Toothpickのinjectionするメソッドの個数による速度差が以下の通り。 https://github.com/stephanenicolas/toothpick/wiki/Benchmark#benchmark-raw-data Androidの環境でいうと、injectionするメソッド数が1000個超えるとかな大規模なものになることはまだそこまで多くはないはずなので、速度としては申し分ないのではないでしょうか。 初期設定では一部reflectionを使っている 以下の通り、default設定ではfactoriesの読み込みやmember injectorsを読み込むにあたりreflectionを使っているらしいです。 https://github.com/stephanenicolas/toothpick/wiki/Configurations ただ、このreflectionはOFFにすることができるそうな。そのためには以下の通りToothpickを使う時に reflectionFree の設定を与える必要があるとのこと。これにより、完全にToothpickはreflectionなく動作し、高速になると。 ベンチマークはこちら => ★ 確かに、reflectionの有無で何倍も速度差がでますね。ここら辺の積み重ねで性能差が大きく出てきそうな。 scopeにより意図しないクラッシュを避ける Scopeという概念を入れることで、Scopeに属さないfragmentなんかを意図せず読んだ時にクラッシュする、というような不用意なinjectionを回避できるようにしているそうな。ここはまだこのツールの中身を追ってはいないのでなるほどなという感じ。 あと、ここなんかでは、メモリリークに対するこのツールの見解といったところも記述されています。 締め まだざっとWikiなんかを眺めただけで中身を追ってはいないのですが、tree based DIが、学習コストがあまり高くなくとも比較的容易に使えるライブラリなのであれば結構有力なDIの選択肢になるのではないかなと感じています。個人的には、toothpickにはテストコード向けの機能も提供しているので、テストコード書くにあたってもかきやすいものであればなお嬉しいなという感じです。シンプルにinjectionするモジュールの関係性や使い方を理解して使えるのであれば、内部品質向上へ大きく寄与するし、テストコードを描きやすいのであればクラッシュや機能不全などの外部品質の担保にも寄与できると期待できるためです。 ちなみに、過去、私はDagger2を学んでいました。このBlogの過去のDagger2関係 => 検索 その中でDagger2を使ってテストコードのDIによるテストも書きはしたのですが、そんなに簡単に書けた!というほどでもなかった記憶が。。。 ともあれ、Dagger2と同じくらいには使い方などを追ってみようと思っています。(少し気長に…)More
[Android]Google Test Labs to Firebase
Google Test Labsを覗いてみると、以下の通りFirebaseに移行したとありました。 Firebaseに統合されていることは知ってたのですが、完全にFirebaseの一部に移行するのですね。モバイル系プラットフォームのFirebase化への本気度を感じます。 Test Lab is moving to Firebase. Visit the Firebase console to use Firebase Test Lab for Android. 以下にドキュメントがありました。 https://firebase.google.com/docs/test-lab/#implementation_path サポートしているスクリプトは以下のよう。 Espresso, Robotium or UI Automator 2.0 instrumentation tests written specifically to exercise your app. Robo test, which analyzes the structure of your app’s user interface and then explores it automatically by…More
[Android]codelabsがいろいろ参考になる
最近、Googleのcodelabsを覗きながらGoogleIOであった新しめなツールの把握をしています。 https://codelabs.developers.google.com/ どのくらい時間かかりそうかも書いているし、実際経験したことある人だと表示されている時間ほどチュートリアルにも時間がかからないので効率的にざっとした内容は把握できそうな気がします。 ConstraintLayout ConstraintLayoutを試してみました。 こちら AppleのStoryBoard上でAutoLayoutを操作する感じで使えますね。 サンプルを基に、自分で少しやってみました。 https://github.com/KazuCocoa/myconstraintlayout XMLは微調整をする時以外見なくてよさそうな感じまでなると良いですね。古くからAndroidアプリ開発されている方はXMLとの対話の方がまだ効率的なのかな。 Android Testing Codelab こちら これはオマケみたいなものです。 Espressoを使ったサンプルと、MVCの説明ですね。Activityへの依存性を少なくしてテスト可能な範囲を広げるとか、interfaceを定義してその実装をstub/mockするやり方とか、そこらへんの導入が書いています。 Espresso-contrib はRecyclerViewに対して使えるメソッドを提供していたのは知ってたのですが、 DrawerActions や DrawerMatchers に対してもそうであったのですね。ここは知らなかった… (と思ったら、ATSLのページには書かれていた.. Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource) あと、@SmallTest, @MediumTest, @LargeTestの説明あったけれど、社内で定めた基準とだいたい同じ感じ。 そういえば、Espressoでは、waitとか用意しなくて良いのね。Espressoのテスト、ちょっと調整しよう。 Espresso waits until the UI is idle before it moves to the next operation. Likewise, it waits for AsyncTask…More
Espresso-core2.2.2とRunner/Rules 0.5が公開されていたのでコードを見る
espresso 2.2.2と、Runner/Rules 0.5が公開されていた。Silent releaseぽい。 https://google.github.io/android-testing-support-library/downloads/release-notes/index.html 更新情報の中で気になったところをメモ。sampleとかも書かれていないので、コードを直接追ってみました。コードまで追ってみた結果としては、 withResourceName だけ気にしていれば良いかなという感じ。 New feature Added checks for enabled animations and transitions New ViewMatcher API: withResourceName notable change ActivityTestRule, UiThreadTestRule, IntentsTestRule and ServiceTestRule are out of beta. dive into code withResourceName コードを見た感じだと以下。 withResourceName は resource idではなく、name属性から要素を特定できるっぽい。 android/support/test/espresso/matcher/ViewMatchers.java This file contains hidden or bidirectional Unicode text that may be interpreted or…More
[Android]delete data stored in AccountManager via adb
As you know, you can remove local application data via adb command. The command is very useful to do Android test against release module with uiautomator, Appium an so on. But, if your application use AccountManager provided by Android platform, the command can’t remove the data stored via account manager. What you can do is……More
[Android]duplicateFileException when import espresso-web
個人アプリのいろいろなライブラリの更新をしていると、以下のようにespresso関係でエラーが出るようになってました。 Webでざっと調べると、以下を見つけることができました。 http://openstackwiki.org/wiki/Espresso-Web_importieren_verursacht_duplicateFileException http://stackoverflow.com/questions/33800924/espresso-web-import-causes-duplicatefileexception 公式では、以下のcontribにはcoreが入っていると書かれているのでその場合はcoreは不要、とは書かれてれているのですが、これはよくわからなかったです。 ちなみに、以下のGradleサンプルでは大概のespressoに必要なものは入ってました。 https://google.github.io/android-testing-support-library/downloads/index.html ひとまず、stackoverflowにあるように以下を packageOption に追加することでエラーを回避することができました。んーむ。More