EMMAfinal 146KB Sep 01 2007 02:20:16 PM

Download Report

Transcript EMMAfinal 146KB Sep 01 2007 02:20:16 PM

The quick fact of EMMA
Seiya Kawashima
Loyola University Chicago
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Here is the overview

Two modes of EMMA.

When to use which mode.

What depth EMMA can detect coverage?

When EMMA can detect only partially?

How about unit test with EMMA?

Appendix
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Two modes of EMMA
1. On-The-Fly
Instrumenting as classes are loaded by JVM.
Three stages( Instrument, Execute
and Report) are into ONE step.
2. Offline
Before classes are loaded by JVM.
Their instrumented data is on disk .
Three stages (Instrument,Execute
and Report) are INDIVIDUAL steps.
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Words are enough!
On-The-Fly :
Instrume
ntExecut
e
Report
All on MEMORY !
Offline :
Instrume
nt
*.em
(metadat
a)
All on Disk !
Execut
e
*.ec
(covera
ge
Report
runtime
data)
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
txt,
html,
or
xml
When to use which mode
1.On-The-Fly
a)When you want to experiment with it.
b)When you use unit tests with EMMA.
c)When you don't have large projects with bunch of people.
2.Offline
a)When you have large projects with
groups of people.
b)When you want to combine the results
from different teams into a report.
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
What depth that EMMA can detect
Class
 Method
 Line
 Basic Block

These are the default setting especially
for HTML reports. All of these depths
are on the type of report on EMMA.
It looks like this......
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
EMMA can detect only partially when?
As you can see, there is a yellow line on the screen.
The yellow line means that EMMA executed.
Why ? Because on the yellow line, there are
two commands combined with'&'.
Since the test covered partially on the line,
it is executed partially.
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
How about unit test on EMMA ?
Unit test classes can't generate necessary data for Off
line mode. Nobody wants to instrument test classes but
target classes.
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Appendix A
Here is why we can't use unit tests with offline mode.
1. Make a directory for the source class and compile the target class
mkdir Testout
javac -d out -g -cp “where junit.jar is”:. targetTest.java
2. Make a directory for the instrumented class and instrument the class
mkdir Testinstr
java emma instr -d Test -ip Testinstr
3. Get runtime coverage data for the test
java -cp Testinstr:Testout:. -cp “where junit is”:. junit.textui.TestRunner targetTest
(Then get an error on this line since there is no main there.)
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Appendix B.1
Here is the description of step-by-step On-The-Fly mode on
command line.
1. Make sure if you use Unix-like or Windows operating system.
2. Compile the target class with this command.
Javac -g target.java
(-g means get full debug information which is useful on EMMA.)
3. Now, you are ready to use On-The-Fly mode with this command.
Java -cp /...../emma.jar( : || ;) emmarun -cp . . target
(Tell java where emma.jar is with the separator
' :' on Unix-like operating system and ';' on Windows operating system.
And you
typeget
“emmarun”
command
followed by “-cp”,where the target is
4.
Then,
a
text
report
by
default.
for the
command
If you
want to get an html report, you can put “-r” for “emmarun”
command like this.
Java -cp /.../emma.jar(: || ;) emmarun -r html -sourcepath /.../target cp . target
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
Appendix B.2
Here is the description of step-by-step Offline mode
on command line.
1. The same as On-The-fly mode.
2. Make a directory for the target original class to clear which is original
and instrumented
with this command.
out time we have a directory, so use it as a target directory and
3. mkdir
Since this
compile it with
this command.
javac -d
-g target.java
4. Make
oneout
more
directory for the instrumented target code.
mkdir outinstr
5. Now. It's ready to instrument it.
java emma instr -d outinstr -ip out
(“emma” and “instr” commands are for Offline mode. And “instr” is
for instrumenting.
“-d” means that you can specify the destination directory, and “-ip”
EMMA
means©that
Continued to the next
Copyright
2001-2005 Vlad Roubtsov All
Appendix B.2 ( Continued)
6. It's time to execute it with this command.
java -cp outinstr:out:. TargetMainClass
(As a result, you get “coverage.ec” by default)
7. Finally we can get the report from those commands.
java emma report -r txt,html - sourcepath /../target -in coverage.em in coverage.ec
Appendix C
There is a property file of EMMA called “emma_default/properties”
in the same directory as “emma.jar”. Using this file, you can change
the default values anyway you want easily. Here is the description of it.
1. Save “emma_default.properties” as “yours.properties” since the file
is
2. read-only.
Then modify “yours.properties”.
3. Use this command to set the properties file for EMMA (For both
modes)
java -cp /.../emma.jar:. Emmarun -properties yours.properties -cp .
java emma run -cp /.../emma.jar :. -properties yours.properties
target
-cp .target
EMMA:Copyright © 2001-2005 Vlad Roubtsov All
There is one more thing .....