2013年4月18日 星期四

Test Framework on Android

   In the test case, we can divide into unit and integration test(also call it is white and black box test). we always   use the unit test to make sure the correctness. and integration test to make sure it in user's way. Android provide the framwork's to finish this work:

Test Project : Include the mock object for Android's object, and also test the key objects : Activity and Service. in the other way, it's support emma(the code coverage tool for test case). the usage step show as follow:
  1. android create test-project -m ../MyAndroidProject-n MyTestProject -p MyActivityTest
  2. ant emma debug install test #Run the test case on debug build with code coverage analysis
UI Test : It's new feature in Android SDK 16 and high. it can write the script(Java) to control the UI Components( for example: click button, swipe list view and press the back key). looks like it's not support dragging touch event. the usage step show as follow: 

  1. android create uitest-project -n my_ui_test_project -t 1 -p my_ui_test_project_folder
  2. ant build
  3. adb push bin/my_ui_test_project.jar /usr/local/tmp/
  4. adb shell uiautomator my_ui_test_project.jar -c com.yourtestcasepackagename.app.Main
Monkey : Send bunch of key/touch event into Application.
example : adb shell monkey -p com.yourpakcagename.app -v 50000 (send the number of events)


In the future work, we can integration it into the Jenkins service.


沒有留言:

張貼留言