public class CoberturaInstrumenter extends java.lang.Object
DetectDuplicatedCodeClassVisitor
- we look for the same ASM code snippets
rendered in different places of destination codeBuildClassMapClassVisitor
- finds all touch-points and other interesting
information that are in the class and store it in ClassMap
.
InjectCodeClassInstrumenter
. Uses {#link ClassMap} to inject
code into the classModifier and Type | Class and Description |
---|---|
static class |
CoberturaInstrumenter.InstrumentationResult
Result of instrumentation is a pair of two fields:
CoberturaInstrumenter.InstrumentationResult.content - bytecode of the instrumented class
CoberturaInstrumenter.InstrumentationResult.className - className of class being instrumented
|
Modifier and Type | Field and Description |
---|---|
private java.io.File |
destinationDirectory
The root directory for instrumented classes.
|
private boolean |
failOnError
If true: The process is interrupted when first error occured.
|
private java.util.Set<java.lang.String> |
ignoreMethodAnnotations
Methods annotated by this annotations will be ignored during coverage measurement
|
private java.util.Collection<java.util.regex.Pattern> |
ignoreRegexes
List of patterns to know that we don't want trace lines that are calls to some methods
|
private boolean |
ignoreTrivial
If true: Getters, Setters and simple initialization will be ignored by coverage measurement
|
private static org.apache.log4j.Logger |
logger |
private ProjectData |
projectData
During the instrumentation process we are feeling
ProjectData , to generate from
it the *.ser file. |
private boolean |
threadsafeRigorous
Setting to true causes cobertura to use more strict threadsafe model that is significantly
slower, but guarantees that number of hits counted for each line will be precise in multithread-environment.
|
Constructor and Description |
---|
CoberturaInstrumenter() |
Modifier and Type | Method and Description |
---|---|
void |
addInstrumentationToSingleClass(java.io.File file)
Analyzes and instruments class given by file.
|
java.io.File |
getDestinationDirectory()
Gets the root directory for instrumented classes.
|
java.util.Collection<java.util.regex.Pattern> |
getIgnoreRegexes()
Gets list of patterns to know that we don't want trace lines that are calls to some methods
|
CoberturaInstrumenter.InstrumentationResult |
instrumentClass(java.io.File file)
Analyzes and instruments class given by path.
|
CoberturaInstrumenter.InstrumentationResult |
instrumentClass(java.io.InputStream inputStream)
Analyzes and instruments class given by inputStream
Also the
projectData structure is filled with information about the found touch-points |
void |
setDestinationDirectory(java.io.File destinationDirectory)
Sets the root directory for instrumented classes.
|
void |
setFailOnError(boolean failOnError) |
void |
setIgnoreMethodAnnotations(java.util.Set<java.lang.String> ignoreMethodAnnotations) |
void |
setIgnoreRegexes(java.util.Collection<java.util.regex.Pattern> ignoreRegexes)
Sets list of patterns to know that we don't want trace lines that are calls to some methods
|
void |
setIgnoreTrivial(boolean ignoreTrivial) |
void |
setProjectData(ProjectData projectData)
Sets
ProjectData that will be filled with information about touch points inside instrumented classes |
void |
setThreadsafeRigorous(boolean threadsafeRigorous) |
private static final org.apache.log4j.Logger logger
private ProjectData projectData
ProjectData
, to generate from
it the *.ser file.
We now (1.10+) don't need to generate the file (it is not necessery for reporting), but we still
do it for backward compatibility (for example maven-cobertura-plugin expects it). We should avoid
this some day.private java.io.File destinationDirectory
private java.util.Collection<java.util.regex.Pattern> ignoreRegexes
private java.util.Set<java.lang.String> ignoreMethodAnnotations
private boolean ignoreTrivial
private boolean failOnError
private boolean threadsafeRigorous
public CoberturaInstrumenter()
public CoberturaInstrumenter.InstrumentationResult instrumentClass(java.io.File file)
Also the projectData
structure is filled with information about the found touch-points
file
- - path to class that should be instrumentedpublic CoberturaInstrumenter.InstrumentationResult instrumentClass(java.io.InputStream inputStream) throws java.io.IOException
Also the projectData
structure is filled with information about the found touch-points
inputStream
- - source of class to instrument *java.io.IOException
public void addInstrumentationToSingleClass(java.io.File file)
If the destinationDirectory
is null, then the file is overwritten,
otherwise the class is stored into the destinationDirectory
Also the projectData
structure is filled with information about the found touch-points
file
- - source of class to instrumentpublic java.io.File getDestinationDirectory()
public void setDestinationDirectory(java.io.File destinationDirectory)
public java.util.Collection<java.util.regex.Pattern> getIgnoreRegexes()
public void setIgnoreRegexes(java.util.Collection<java.util.regex.Pattern> ignoreRegexes)
public void setIgnoreTrivial(boolean ignoreTrivial)
public void setIgnoreMethodAnnotations(java.util.Set<java.lang.String> ignoreMethodAnnotations)
public void setThreadsafeRigorous(boolean threadsafeRigorous)
public void setFailOnError(boolean failOnError)
public void setProjectData(ProjectData projectData)
ProjectData
that will be filled with information about touch points inside instrumented classesprojectData
-