Interface IProjectCoverage
Represents settings of an NDepend project concerning code coverage file(s) to load to obtain code coverage metrics.
public interface IProjectCoverage
- Extension Methods
Properties (6)
CoverageDir
Gets or sets a directory path that contains some coverage files to import. A null value means that this facility is not used.
IDirectoryPath CoverageDir { get; set; }
Property Value
Remarks
In addition to the specified list of coverage files, a directory can be specified to import all files in this directory as coverage files. This facility is useful to just dump all coverage files in a directory at build time, and don't need to care about their number nor names. If some files in this directory are not recognized as coverage files, a warning will be emitted.
CoverageDirFilter
Gets or sets a wildcard filter string that is used to locate coverage files when the CoverageDir is set.
string CoverageDirFilter { get; set; }
Property Value
Remarks
No filter means only files in coverage directory are taken account.
Filter "" matches all files in coverage directory (same as above).
Filter "***.xml" matches all files with .xml extension (case-insensitive) in coverage directory and in all its child directories (recursive).
Filter "Cov*" matches all files in coverage directory's child directories whose name starts with Cov (case-insensitive).
CoverageExclusionFile
Gets or sets a file path that contains some data to exclude some projects or some code elements from code coverage statistics.
IFilePath CoverageExclusionFile { get; set; }
Property Value
Remarks
In .NET a coverage exclusion file is a file with extension .runsettings file with a CodeCoverage section.
CoverageFiles
Gets a read-only list of coverages files paths.
IReadOnlyList<IFilePath> CoverageFiles { get; }
Property Value
Remarks
The list returned is a clone. Hence it doesn't reflect any modification in the original collection.
Use AddCoverageFile(IFilePath) and RemoveCoverageFile(IFilePath) methods to modify the collection of coverages files paths.
PersistCoverageSequencePoints
Gets or sets whether the analysis persists the coverage sequence points (the per-statement covered / not covered ranges) of every source file into the SourceFiles.zip file written next to the analysis result file.
bool PersistCoverageSequencePoints { get; set; }
Property Value
Remarks
By default the analysis result only persists per-method coverage ratios. With this option set, the report built against a baseline analysis result that persisted its sequence points can show, in the baseline version of a source file, which statements were covered by tests at that time.
This option is ignored when ZipSourceFiles is false or when no coverage data is imported.
Default value is true.
UncoverableAttribute
Gets or sets the full name string of the uncoverable attribute.
string UncoverableAttribute { get; set; }
Property Value
Remarks
Through this option, the user can define an attribute that tags uncoverage methods, types or assemblies.
NDepend will then take care of this attribute and compute coverage ratio adequately.
For example, if all methods of a type are 100% covered by tests except a method that calls a blocking method such as MessageBox.Show(), this method can be tagged with the uncoverable attributes and as a result, the type.PercentageCoverage ratio is artificially maintained to 100%.
The NDepend.API offers the attribute class UncoverableByTestAttribute for default uncoverable attribute, but you can define your own uncoverable attribute and set this property adequately.
The name of the uncoverable attribute must be formatted "{namespace}.{typeAttribute}". For example: "NDepend.Attributes.UncoverableByTestAttribute"
- See Also
Methods (3)
AddCoverageFile(IFilePath)
Adds the coverage file path.
bool AddCoverageFile(IFilePath coverageFilePath)
Parameters
coverageFilePathIFilePathThe coverage file path to add.
Returns
- bool
Returns true only if the path is correctly added.
When adding a duplicate path, the method does nothing and returns false.
Remarks
The list can't contains duplicate path.
If the path is added, the event IProject.SettingsChanged is triggered with the flag ProjectSettings.Coverage_Settings activated.
GetCoverageDescription()
Returns a plain english description of the coverage files.
string GetCoverageDescription()
Returns
RemoveCoverageFile(IFilePath)
Removes the coverageFilePath from the collection of coverage files.
bool RemoveCoverageFile(IFilePath coverageFilePath)
Parameters
coverageFilePathIFilePathThe coverage file path to remove.
Returns
- bool
If the path is not found, the method does nothing and returns false.
Returns true only if the path is correctly removed.
Remarks
If the path is removed, the event IProject.SettingsChanged is triggered with the flag ProjectSettings.Coverage_Settings activated.