-
Notifications
You must be signed in to change notification settings - Fork 15
API
The two main classes of the flacoco API are Flacoco
and FlacocoConfig
.
This class serves as the main entry point of flacoco. It takes as a single parameter a FlacocoConfig
object, which contains all the information flacoco requires, and is executable through the method run()
which returns a FlacocoResult
containing the execution results.
By default, the return FlacocoResult
will be populated with a mapping between Location
keys and Suspiciousness
values, as well as a set of failing TestMethod
s.
These default results are obtainable through getDefaultSuspiciousnessMap()
and getFailingTests()
respectively.
FlacocoConfig config = new FlacocoConfig();
// set config options
Flacoco flacoco = new Flacoco(flacocoConfig);
FlacocoResult result = flacoco.run();
Map<Location, CtStatement> mapping = result.getLocationStatementMap();
Set<TestMethod> failingTestMethods = result.getFailingTests();
Spoon mode
If the option computeSpoonResults
is set in the config, the returned FlacocoResult
will also be populated with a mapping between CtStatement
key and Suspiciousness
values.
More information on how source code locations are mapped to CtStatement
s can be found under SpoonConverter.
FlacocoConfig config = new FlacocoConfig();
config.setComputeSpoonResults(true);
// set config options
Flacoco flacoco = new Flacoco(flacocoConfig);
FlacocoResult result = flacoco.run();
Map<CtStatement, Suspiciousness> mappingSpoon = result.getSpoonSuspiciousnessMap();
This class serves as the configuration manager of flacoco.
Through it, you can set all the options that will be used during the execution of flacoco. A comprehensive list of options will be provided soon in this page. In the meanwhile, the automatically generated usage message under CLI
contains information about what options are available.