Skip to content
André Silva edited this page Sep 2, 2021 · 8 revisions

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.

Default mode

By default, the return FlacocoResult will be populated with a mapping between Location keys and Suspiciousness values, as well as a set of failing TestMethods.

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 CtStatements 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.

Clone this wiki locally