AndroidMonkey is an Android Library. It is, in fact, a copy of the original Android Monkey Toolhttp://developer.android.com/guide/developing/tools/monkey.html and made as a library for testing and analysis (e.g. code coverage) purposes.
Tester/User can easily use the library to create random test cases to test android apps with GUI.
Why this library:
You can use this library to create random test cases for your application, with just few lines of code
You can add your assertions to access the state of the SUT (you can hardly do this with the Android Monkey Tool)
You can do Coverage analysis of random testing on Android Application, this is useful for Research Purpose (like what I'm doing)
실행방법
우선, 위 open project에서 다운받은 example code를 ant로 빌드환경에 맞게 update를 해야한다.
이러한 작업을 완료한 3개의 파일을 본 블로그에 첨부한다.
1) monkey testing할 project를 target smartphone에 설치 한다.
명령어: ant emma debug install
root@ubuntu:~/Android_Application_source/testingProjectPackage/NotePad# ant emma debug install
Buildfile: /root/Android_Application_source/testingProjectPackage/NotePad/build.xml
emma:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.2.1
[checkenv] Installed at /root/Android_Application_tools/android-sdk-linux_r22
install:
[echo] Installing /root/Android_Application_source/testingProjectPackage/NotePad/bin/AntNotePad-debug.apk onto default emulator or device...
[exec] 554 KB/s (63571 bytes in 0.112s)
[exec] pkg: /data/local/tmp/AntNotePad-debug.apk
[exec] Success
BUILD SUCCESSFUL
Total time: 6 seconds
2) app test project를 설치한다.
해당 project는 AndroidMonkey project와 종속성이 있다. 왜냐하면, 테스팅 수행 과정에서 random event를 생성해서 testing을 수행하기 때문이다.
root@ubuntu:~/Android_Application_source/testingProjectPackage/NotePadMonkeyTester# ant emma debug install
Buildfile: /root/Android_Application_source/testingProjectPackage/NotePadMonkeyTester/build.xml
emma:
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.2.1
[checkenv] Installed at /root/Android_Application_tools/android-sdk-linux_r22
3) 테스팅을 실행한다.
환경은 notepad 어플리케이션에 2개의 post를 등록한 상태에서 실행을 한다.
명령어: adb shell am instrument -e coverage true -w com.example.android.notepad.test/android.test.InstrumentationTestRunner
특이사항: 위 명령어를 실행하면 app project의 bin 디렉터리에 coverage.em 파일이 생성 되어 진다.
root@ubuntu:~/Android_Application_source/testingProjectPackage/NotePadMonkeyTester# adb shell am instrument -e coverage true -w com.example.android.notepad.test/android.test.InstrumentationTestRunner
com.example.android.notepad.test.RandomTest:.
Test results for InstrumentationTestRunner=.
Time: 49.75
OK (1 test)
3) report 생성.
주의: coverage.em이 없을 경우, app project 디렉터리에서 ant instrument 명령어를 실행해서
root@ubuntu:~/Android_Application_source/testingProjectPackage/NotePad# adb pull /data/data/com.example.android.notepad/files/coverage.ec .
17 KB/s (691 bytes in 0.039s)
'Computer Science > EMMA' 카테고리의 다른 글
WordPress에 대한 codecoverage 측정 방법 연구 (0) | 2013.10.31 |
---|---|
Android Ant Builds: 여러 장치가 존재 할때 (0) | 2013.10.18 |
EMMA를 실행 하는 App에 대해서 사용 하는 방법. (1) | 2013.08.25 |
EMMA 설정 방법 (0) | 2013.08.23 |