隨著近幾年Android裝置廣受市場的歡迎,Android應用程式數量快速的成長,為確保Android應用程式的品質,Android測試受到廣泛的重視,雖然目前已有些工具可測試Android應用程式,然而這些工具對Android應用程式圖形使用者介面(Graphical User Interface, GUI)測試的支援仍然有限。為降低Android應用程式GUI測試的困難,本論文提出一個Android GUI自動化測試方法,此方法包含一個使用者事件錄製與重播(Capture/Replay)框架和一個GUI測試模型。其中使用者事件錄製與重播框架可以擷取使用者發送的GUI事件,並將其轉換成Robotium測試腳本以重播使用者的操作行為,該框架在錄製過程中並允許插入斷言(assertion),以驗證Android應用程式的輸出是否正確。另外,本論文提出的GUI測試模型為一階層式的狀態機(hierarchical state machine),可萃取Android 應用程式GUI元件可能的互動行為,該模型除了有助於了解Android 應用程式的動態行為外,亦可用來產生使用者事件可能的序列,協助測試案例的推導。此外,本論文並實作一套Android應用程式測試輔助工具,自動化Android應用程式的GUI測試,可幫助降低撰寫與執行Android應用程式測試案例所需的時間和成本。
With the widespread popularity of Android devices, the number of Android applications has increased dramatically in recent years. In order to assure the quality of the applications, Android testing has drawn extensive attentions. Although several tools have been proposed for testing Android applications, those tools are still inadequate in supporting the testing of Android’s Graphical User Interface (GUI). To facilitate the GUI testing of Android applications, this thesis proposes an approach to automate the Android GUI testing. Specifically, the approach consists of a user event Capture/Replay framework and a GUI test model. The Capture/Replay framework can intercept user events and convert them into Robotium test scripts for replaying the actions of users. It also allows inserting assertions when capturing user events for validating the correctness of the application’s outputs. Moreover, the proposed GUI test model is a hierarchical state machine which is used to abstract the interactions of GUI components for Android applications. It not only can facilitate the understanding of the dynamic behavior for Android applications, but also can be used to generate possible user event sequences for deriving test cases. In addition, a supporting tool is implemented to automate the GUI testing for Android applications. With the proposed tool, the time and effort to develop GUI test cases and to execute the testing for Android applications can be reduced significantly.