????????
????EMMA ?????????????? Java ???????????????????湤??????????????? Java ???????????в???????????й???????????????????????????????????????????????????? EMMA ???????????????????? EMMA ??????????????“?????”??????? EMMA ????????????????????????? EMMA ???????????????????
???????
?????????????? EMMA ????????????????????? EMMA ??????????? emma.jar ???????????????????????????? EMMA ???????
????EMMA ?????? Java ???????????
?????????????????????????????? WAR ??????? JAR ????????????? WAR ???????WebSphere Portal Server ?????С?????????????У???????????滻????????????
???????????????? EMMA ?????
????EMMA ???????????????????????????????鴝??????и????????Щ??????????λ?????????
?????????????????У????????????????????????????????????????????????????????????????У???????????????????????????????????????????????????????????????????????????????????????и??м?????????????????У??????????????????????????????????к?鴝??????????????ο???
?????????????????а???????????????????????????????δ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????棬????????????г?????????????????????????????滹???????????????Χ??????????????????
??????????????????δ?????????????м????
????????????????????????Щ???????????б???????????
??????????????????????????顣???????????????£?????????????????????????????????δ???????????????????????????????
?????????????????????????????????????????????
????????? EMMA ??ò????????????У??????????????????棬????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????棬?????????????????????????????????????ɡ?
??????????????????? Agile ??????????????У??????????????????????Ч???????????????????????????????????????????????????????????????????????
????EMMA ?????????е????
???????????????????? EMMA ????????????е???ù??????衣???????????????????????????????????????????????????????????????в?????????? EMMA ?????
??????????????
????EMMA ??????????????в??????????????????й?????????????????в??????? EMMA ???????????????????????????????????????????????????????????????????????? Java ??????????????????????????????????????????????в????
??????????
????????в???????????????????? Java ??????????? emma.jar ??????????????????JRE ????????? JRE ?????????? EMMA ????????á? emma.jar ?????? EMMA ??????????????? EMMA ???????????????????Щ???????? EMMA ????????
???????????????????????? Websphere Portal Server ?У?????????? JRE ???У?????emma.jar ??? “/opt/WebSphere/PortalServer/java/jre/lib/ext” ???檔??????????У?????·????????????滻??
???????
????EMMA ?????? “instr” ?????????????????????????????? JAR ???? WAR ???? WAR ????????????????????????????в???????????????ü???????1-4??????????????????????μ??????
????????????????
?????????????????????????????????????
?????嵥 1. ??????????????
????/opt/WebSphere/PortalServer/java/jre/bin/java emma instr -m overwrite -ip
????/opt/WebSphere/PortalServer/installedApps/NumberQuizWEB_10yggsru.ear/NumberQuizWEB.war/WEB
????-INF/classes -Dmetadata.out.file=/root/emma/Number_coverage.em
????EMMA: processing instrumentation path
????EMMA: instrumentation path processed in 682 ms
????EMMA: [5 class(es) instrumented?? 0 resource(s) copied]
????EMMA: metadata merged into [/root/emma/Number_coverage.em] {in 72 ms}
??????? JAR ??
????JAR ??????????????????в????????????? JAR ???в???????????? JAR ?????н??????????????????Ч???
?????嵥 2. ?? JAR ?????????
????/opt/WebSphere/PortalServer/java/jre/bin/java emma instr -m overwrite -cp  TestWs.jar -
????Dmetadata.out.file=/root/emma/Number_coverage.em
????EMMA: processing instrumentation path
????EMMA: instrumentation path processed in 675 ms
????EMMA: [7 class(es) instrumented?? 4 resource(s) copied]
????EMMA: metadata merged into [/root/emma/Number_coverage.em] {in 60 ms}
??????? WAR/EAR ??
???????? WAR/EAR ????????????????????У?????????в?????????????????????? J2EE ?????У?????俴???????в????
?????嵥 3. ?? WAR/EAR ?????????
????/opt/WebSphere/PortalServer/java/jre/bin/java emma instr -m overwrite 
????-ip NumberQuizWEB.war -Dmetadata.out.file=/root/emma/Number_coverage.em
????EMMA: processing instrumentation path
????EMMA: instrumentation path processed in 610 ms
????EMMA: [5 class(es) instrumented?? 0 resource(s) copied]
????EMMA: metadata merged into [/root/emma/Number_coverage.em] {in 94 ms}
????????????
????EMMA ???????? JAR ?????????в??????????? JAR ?????????а?????????????????????в??????????????y?????????????????Щ??????????????????????? EMMA ??????????????????????????
?????嵥 4. ?????????
????/opt/WebSphere/PortalServer/java/jre/bin/java emma instr -m overwrite -cp  TestWs.jar
????-ix +org.wstest.service.* -Dmetadata.out.file=/root/emma/Number_coverage.em
????EMMA: processing instrumentation path
????EMMA: instrumentation path processed in 637 ms
????EMMA: [4 class(es) instrumented?? 6 resource(s) copied]
????EMMA: metadata merged into [/root/emma/Number_coverage.em] {in 107 ms}
????????????????????嵥2??????? JAR ??????????????? org.wstest.service.* ?????????????????4????
?????????1-4?????????????????е?????????????????????????Щ???????н????
???????? “m”????????????????????????????????? “copy” ??“overwrite” ?? “fullcopy” ?????У?“copy” ?? “ fullcopy” ????????????????????????????????????????????????????????????????????????“overwrite” ??????ò??????????????????????÷???????????????????????????????Σ??? “overwrite”???£????????????????????????????????????????????????????????????????????????б????
???????? “ip” ?? “cp” ?????????·???????? “cp” ??????????????У? “ip” ???????????????? JAR ????
???????? “Dmetadata.out.file” ????????????????????????????·????
????EMMA ????? “ix” ??????????????????????????????? “+” ??????????????????????? “-” ???????????????????????
????????????
???????????????????????·?????????Щ??? “*coverage.em” ?????????Щ?????????????????????Щ??????????????????е??????????????е?λ?á?????????????У??????Щ??????????????? EMMA ???????????к??????????????δ???·????????????????????????????Щ?????????????????????????????????????????????? “merge” ???????????Щ???????к???????????????????????????????????????????????????
?????嵥 5. ????????????
????/opt/WebSphere/PortalServer/java/jre/bin/java emma merge
????-input <path1>/coverage1.em??<path2>/coverage.em -out <path>/coverage2.em
?????? “input” ????????????????????????? “out” ???????????????????????
????????????????????????????????????????????????????????????????????????????????????????в????????У? EMMA ????????????й?????????????????
???????в?????????????????????
??????????????????????????????????????в????????? EMMA ?????????е?????м????????????????????????????С???ε? JVM ?????????м????????????????????????浽 “*.ec” ??????С??????????????????У? JVM ???????????????????????????????????????????д??????????????£?????е??????????????????е??????????????嵥5-7?????????????????????????????????????????
?????嵥 6. ??????????????????????
????/opt/WebSphere/PortalServer/java/jre/bin/java -cp emma.jar emma ctl –connect
????auscsdpfvtvm15.bto.ibm.com:47653 -command coverage.dump??/root/emma/Number_coverage.ec
????EMMA: processing control command sequence
????EMMA: executing [coverage.dump (/root/emma/Number_coverage.ec????true)]
????EMMA: coverage.dump: runtime coverage data remotely merged into
????[/root/emma/Number_coverage.ec] {in 83 ms}
????EMMA: coverage.dump: command completed in 96 ms
????EMMA: control command sequence complete
?????嵥 7. ?????????????????
????/opt/WebSphere/PortalServer/java/jre/bin/java -cp emma.jar emma ctl -connect
????auscsdpfvtvm15.bto.ibm.com:47653 -command coverage.get??/root/emma/Number_coverage.ec
????EMMA: processing control command sequence
????EMMA: executing [coverage.get (/root/emma/Number_coverage.ec??true??true)]
????EMMA: coverage.get: local copy of coverage data merged into
????[/root/emma/Number_coverage.ec] {in 39 ms}
????EMMA: coverage.get: command completed in 79 ms
????EMMA: control command sequence complete
?????????????????????????? “coverage.ec” ?У? “coverage.ec” ???????????????????????????????????????
?????嵥 8. ????????????
????/opt/WebSphere/PortalServer/java/jre/bin/java -cp emma.jar emma report -r html -in
????/root/emma/Number_coverage.em??/root/emma/Number_coverage.ec -
????Dreport.html.out.file=/root/emma/Number_coverage.html -Dreport.metrics=class:80
????(??method:75)
????EMMA: processing input files
????EMMA: 2 file(s) read and merged in 42 ms
????EMMA: writing [html] report to [/root/emma/coverage/Number_coverage.xml]
???????????????????????У???????????????????????? “Dreport.metrics” ?????趨??????????????????????????趨???????????????80%??