A Cobertura context holds properties shared by Cobertura instrumentation, test execution and
report creation. Each Test task that is enhanced with Cobertura functionality has an
associated context that ensures that the properties common to all three steps are the same and
that they can only be configured in one place. Cobertura contexts are added to the project as
extensions to allow configuration from the build script. The name of the project extension will
be "cobertura" + the name of the context.
The properties in a context are to a large extent identical to the ones of the
Cobertura-Instrument and Cobertura-Report Ant tasks, see the
reference> for more
information.
| Constructor and description |
|---|
CoberturaContext
(CoberturaExtension pExtension, java.lang.String pName)Create a new CoberturaContext. |
| Type | Name and description |
|---|---|
static org.gradle.api.file.FileCollection |
defaultInputClasses(org.gradle.api.Project pProject)Get the default collection of classes to analyze for test coverage. |
static org.gradle.api.file.FileCollection |
defaultSourceDirs(org.gradle.api.Project pProject)Get the default source directories for the classes to analyze for test coverage. |
org.gradle.api.file.FileCollection |
getAuxClassPath()Get the path containing any classes that shouldn't be analyzed but are needed by the instrumentation. |
java.io.File |
getExecutionDataFile()Get the file holding metadata about the test execution of the instrumented classes. |
java.util.List<java.lang.String> |
getIgnoreMethodAnnotations()Get the list of fully qualified names of annotations with which methods that should be excluded from instrumentation are annotated with. |
java.util.List<java.lang.String> |
getIgnoreMethodNames()Get the list of regular expressions specifying methods names to be excluded from the coverage analysis. |
boolean |
getIgnoreTrivial()Get the ignore trivial property. |
org.gradle.api.file.FileCollection |
getInputClasses()Get the classes to analyze for test coverage. |
java.io.File |
getInstrumentationDataFile()Get the file holding metadata about the instrumented classes. |
java.io.File |
getInstrumentedClassesDir()Get the directory containing the instrumented versions of the classes to analyze. |
java.lang.String |
getName()Get this context's name. |
org.gradle.api.file.FileCollection |
getSourceDirs()Get the directories containing the sources of the analyzed classes. |
java.lang.String |
getSourceEncoding()Get the encoding to use when reading the source files in the sourceDirs. |
java.io.File |
getWorkDir()Get the work directory where by default all temporary files, such as instrumented classes and the data file, are put. |
void |
setAuxClassPath(java.lang.Object pClassPath)Set the auxiliary classpath. |
void |
setExecutionDataFile(java.lang.Object pFile)Set the execution data file. |
void |
setIgnoreMethodAnnotations(java.util.List<java.lang.String> pIgnoreMethodsAnnotations) |
void |
setIgnoreMethodNames(java.util.List<java.lang.String> pIgnoreMethodsNames) |
void |
setIgnoreTrivial(boolean pDoIgnore) |
void |
setInputClasses(java.lang.Object pClasses)Set the input classes. |
void |
setInstrumentationDataFile(java.lang.Object pFile)Set the instrumentation data file. |
void |
setInstrumentedClassesDir(java.lang.Object pDirectory)Set the instrumented classes directory. |
void |
setSourceDirs(java.lang.Object pDirs)Set the sources directory. |
void |
setSourceEncoding(java.lang.String pEncoding)Set the source encoding. |
void |
setWorkDir(java.lang.Object pDirectory)Set the context's work directory. |
| Methods inherited from class | Name |
|---|---|
class ProjectAware |
getProject |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Is the context enabled? In a disabled context, the tests are run with the original classes
under test, not the instrumented ones, and no coverage report will produced for the test run.
Default is true, meaning that the tests will run with instrumented classes and that a
coverage report will be produced.
Create a new CoberturaContext.
pExtension - The global Cobertura project extension with default values for some
of the context's properties.pName - The name of this context, used as default name for the work directory.Get the default collection of classes to analyze for test coverage.
pProject - The project to get the default input classes from.Get the default source directories for the classes to analyze for test coverage.
pProject - The project to get the default source directories from.Get the path containing any classes that shouldn't be analyzed but are needed by the instrumentation. Default is no auxiliary classpath.
Get the file holding metadata about the test execution of the instrumented classes. This file contains updated information about the instrumented classes from the test runs. It is an updated version of the instrumentation data file, created by the test task and used by the reports task. The default value is a file named "cobertura.execution.ser" in the context's work directory.
Get the list of fully qualified names of annotations with which methods that should be excluded from instrumentation are annotated with. Default is the value of the corresponding property in the global Cobertura project extension.
Get the list of regular expressions specifying methods names to be excluded from the coverage analysis. Note that the classes containing the methods will still be instrumented. Default is is the value of the corresponding property in the global Cobertura project extension.
Get the ignore trivial property. If this property is true, constructors/methods that contain one line of code will be excluded from the overage analysis. Examples include constructors only calling a super constructor, and getters/setters. Default is the value of the corresponding property in the global Cobertura project extension.
Get the classes to analyze for test coverage. The default value is all files in the output classes directory of the main source set. Used as input by the instrumentation task.
Get the file holding metadata about the instrumented classes. This file contains information about the names of the classes, their method names, line numbers, etc. It is created by the instrumentation task. The default value is a file named "cobertura.instrumentation.ser" in the context's work directory.
Get the directory containing the instrumented versions of the classes to analyze. Used as output directory by the instrumentation task and as input directory by the test task. The default value is a directory named "instrumented" in the context's work directory.
Get this context's name.
Get the directories containing the sources of the analyzed classes.
Get the encoding to use when reading the source files in the sourceDirs. The
platform's default encoding will be used if this property is null. Default is the value from
the corresponding property in the global Cobertura project extension.
Get the work directory where by default all temporary files, such as instrumented classes and the data file, are put. The default is a directory with the context's name in the global Cobertura project extension's work directory.
Set the auxiliary classpath. The specified classpath will be resolved relative to the project directory.
pClassPath - The auxiliary classpath, possibly null.Set the execution data file. The specified file will be resolved relative to the project directory.
pFile - The execution data. Passing null will effectively restore the default value.Set the input classes. The specified classes will be resolved relative to the project directory.
pClasses - The input classes. Passing null will effectively restore the default value.Set the instrumentation data file. The specified file will be resolved relative to the project directory.
pFile - The instrumentation data. Passing null will effectively restore the default
value.Set the instrumented classes directory. The specified directory will be resolved relative to the project directory.
pDirectory - The instrumented classes directory. Passing null will effectively
restore the default value.Set the sources directory. The specified directory will be resolved relative to the project directory.
pDirectory - The sources directory. Passing null will effectively restore the default
value.Set the source encoding.
pClassPath - The source encoding. Specifying null means that the platform's default
encoding should be used..Set the context's work directory. The specified directory will be resolved relative to the project directory.
pDirectory - The work directory. Passing null will effectively restore the default
value.Groovy Documentation