Menu

Instrumenting bytecode a JAR file

2010-06-10
2013-05-09
  • Syed M Ali Shah

    Syed M Ali Shah - 2010-06-10

    Hi everyone,

    Is it possible to instrument a JAR file with emma and run testcases on the jar file to calculate the coverage? If there is any such way to do that please let me know.

    Thanks

    Cheers, Ali

     
  • Ernest Quintin

    Ernest Quintin - 2010-06-30

    Ok, I don't use Ant or such too much so I could not help you there.  That said, to instrument a jar file create a script something like the following:
    java -cp {path_to_emma}/emma.jar emma instr -ip {path_to_my_jar_file}/myProgram.jar -out {path_to_results}/myProgram_coverage.em -merge no -m overwrite

    After instrumentation your jar file will be at least twice as big.  Then run the program using a script something like:
    java -D{my Options} -Demma.coverage.out.file={path_to_results}myProgram_Coverage_file -cp {path_to_emma}/emma.jar :{path_to_myProgram}/myProgram.jar {name_of_main_class}

    After you finish running your test(s) create an HTML report by:
    java -cp {path_to_emma}/emma.jar emma report -in {path_to_results}/myProgram_coverage.em,{path_to_results}/myProgram_Coverage_file -r html -sp {path_to_source_code} -Dreport.sort=+name -Dreport.html.out.file={path_to_results}/myProgram.html

    Read the manual for more detail.  Good luck.

     
  • Anonymous

    Anonymous - 2010-10-28

    I am using maven.  I am also running into the same issue.  I am unable to instrument the dependency jars.  Could someone help us pls ?

     

Log in to post a comment.