私たちのチームがGoogleマップを使用するAndroidアプリケーションを作成したとき、マップフラグメントのR.idを使用してテストを作成することができました。私はアプリケーションのコードにアクセスできたので、どの変数を探すべきかを知っていたことに注意することが重要です。
このテストを作成する前に、正しいR.idをターゲットにしていることを確認したかったので、Rファイルに移動し、値をコピーして、
assertEquals(id.satellite,copiedRValue);
これはtrueを返し、変更可能な変数を中心にテストを構築します
initialID = solo.waitForFragmentById(id.satellite); //where id.satellite is defined in the R file, eventually would time out and throw error if fragment was not present
//save the map type, leave
//and do other awsome stuff
//before coming back to the map
finalID = solo.waitForFragmentById(id.satellite);//capture the map fragment that is now displayed, again would time out if this specific fragment was not visible
//assert that the fragments are equal
assertTrue(initialID.equals(finalID);
このテストと他のRobotiumテストで私が抱えていた最大の問題は、メニューを取り込むためにクリックイベントが発生し、Robotiumがクリックを実行せず、クリックでテストが失敗することでした。
Robotiumでのテストはこれが初めてだったので、R.id値を操作してより厳密なテストを作成する他の方法があるかもしれません。