adb locat을 이용하여 test runner tag의 log를 저장, parsing 하여 xml 파일을 만들어 내려고 했다. 오늘 회사에서 하려고 하는 찰나, google 을 한번 더 검색하였고,
이미 만들어져 있는 훌륭한 test runner 를 발견 바로 적용하여 xml 파일을 만들어 낼 수 있었다. 오늘의 첫 블로그는 바로 그 내용에 대한 것이다.
1. Android JUnit Report Test Runner 다운받고 사용하기
아래 사이트에서 Readme 를 꼼꼼히 읽고 그대로 따라하면 모든 것이 만사 OK.
어려운 내용이 전혀 없다.
https://github.com/jsankey/android-junit-report
Android test runner를 상속받아서 이런 것을 할 수 있다는 것을
처음으로 알게 되었다.
2. 따라해도 잘 안되던 몇가지..
- 사용할 test runner 변경하기
AndroidManifest.xml 파일에서 instrumentation tag의 name만 변경해주면 된다.
<instrumentation
android:targetPackage="your package"
android:name="com.zutubi.android.junitreport.JUnitReportTestRunner" />uses-library 는 원래것 그대로 사용하면 된다.
- Eclipse 에서 Run android junit test 하기 전에 run configuration 을 바꿔줘야 한다.
- Readme 파일에 나와 있는 fetch-test-report target 을 다음과 같이 해줘야 실제 test report를 제대로 가져올 수 있다.
- ant build시에 다음과 같이 target 명시해서 test 할 수 있다.<property name="test.runner" value="com.zutubi.android.junitreport.JUnitReportTestRunner" /> <property name="reports.dir" location="test_report" /> <target name="fetch-test-report"> <echo>Downloading XML test report...</echo> <mkdir dir="${reports.dir}"/> <exec executable="${adb}" failonerror="true"> <arg line="${adb.device.arg}"/> <arg value="pull" /> <arg value="/data/data/${tested.manifest.package}/files/junit-report.xml" /> <arg value="${reports.dir}/junit-report.xml" /> </exec> </target>
ant clean coverage fetch-test-report- fetch 된 junit-report.xml 파일을 Eclipse에서 import 해서 보면 정상적으로
생성 되었음을 알 수 있다.
3. 첫 블로그질을 마치고...
처음으로 쓴 짧디 짧은 블로그.
짧지만 글을 쓴다는 것이 이렇게 어려운 일인지 요즘 다시 느끼고 있다.
기술적인 글이지만, 자신의 생각을 논리적으로 잘 표현한다는 것은 참 부러운 능력이다.
더 연습해야겠다.