2013年1月18日 星期五

JInjector - Code coverage tool for J2ME


Overview

Concept

  1. injector
  2. make html report

Step-by-Step

1. checkout the code(include jinjector_tool and jinjector_mobile)
2. get the related lib from web by script
./adddextrapackagesandifiles.sh (copy from jinjector_mobile/)
requirement tool on lib/
google-collect-snapshot-20090211.zip
junit3.8.1.zip
easymock2.4.zip
easymockclassextension2.4.zip
clib-2.2.jar
3. modify the build.xml
build-yourprojectname.xml -> build.xml:
  • <property name="WTK" value ="c:\wtk2.6" /> -> change the value into your WTK folder
  • <property name="emulator.device" value="DefaultColorPhone" /> -> you can change device by setting this value
jinjector.yourprojectname.properties:
  • jars: c:/wtk2.6/lib/cldcapi10.jar... -> your_WTK_folder/lib/cldcapi10.jar...
4. put your source and test case
jinjector_mobile\src : your source
jinjector_mobile\tests_to_inject : your test case
also you can change the value of srcdir:
<target name="injectiontests" depends="unittests"  description="Compiles the tests to inject">
<javac srcdir="${basedir}/tests_to_inject" ...
...
...
<target name="compile" depends="debug_ant, extract"  description="Compiles the source">
<javac srcdir="${basedir}/src" ...
5. build test case with jinjector
ant build
  • it can auto run the emulator from WTK

    figure. auto run the emulator from WTK

figure. end of test and output the log of coverage
hint: the log will put in here in experiential
lcov file place on Windows 7
direction: {UserDir}/j2mewtk/{WTK_Version}/appdb/{Device_Name}/filesystem/root1/{Log_Name}
example: C:/Users/prada.hsiung/j2mewtk/2.5.2/appdb/DefaultColorPhone/filesystem/root1/qq.lcov
lcov file place on Ubuntu 10
direction: ~/j2mewtk/{WTK_Version}/appdb/{Device_Name}/filesystem/roo
example: /home/prada/j2mewtk/2.5.2/appdb/DefaultColorPhone/filesystem/root1/qq.lcov
6. generate report html
  • copy the lcov file into the "/src" where is your source folder
  • generating the report html by genhtml command
  • genhtml qq.lcov*
  • open the index.html in the same folder
    figure. the main page show the percentage of code coverage for each class
figure. under light the code by different color. orange=coverage, red=not coverage yet in the test case

Reference

沒有留言:

張貼留言