-
Notifications
You must be signed in to change notification settings - Fork 15
CLI
André Silva edited this page Jul 29, 2021
·
15 revisions
Displayed below is the full reference of flacoco CLI. You can always obtain this information by running flacoco with the option --help
.
Usage: FlacocoMain [-hVv] [--coverTest] [--includeZeros] [--testRunnerVerbose]
[-o[=<output>]] [-c=<classpath>] [-f=<spectrumFormula>]
[--jacocoClasspath=<customJacocoClasspath>]
[--junitClasspath=<customJUnitClasspath>]
[--mavenHome=<mavenHome>] [-p=<projectPath>]
[--testRunnerJVMArgs=<testRunnerJVMArgs>]
[--testRunnerTimeoutInMs=<testRunnerTimeoutInMs>]
[--threshold=<threshold>] [-w=<workspace>] [--binJavaDir
[=<binJavaDir>...]]... [--binTestDir[=<binTestDir>...]]...
[--srcJavaDir[=<srcJavaDir>...]]... [--srcTestDir
[=<srcTestDir>...]]... [[--format=<format>] |
--formatter=<customExporter>]
[[--junit4tests=<jUnit4Tests>]...
[--junit5tests=<jUnit5Tests>]...]
Flacoco: fault localization
--binJavaDir[=<binJavaDir>...]
Paths to the directories containing java class
files. Defaults to {projectpath}/target/classes
--binTestDir[=<binTestDir>...]
Paths to the directories containing java test class
files. Defaults to {projectpath}
/target/test-classes
-c, --classpath=<classpath>
Classpath of the project under analyzis.
--coverTest Indicates if coverage must also cover the tests.
-f, --formula=<spectrumFormula>
Spectrum formula to use. Valid values: OCHIAI
--format=<format> Format of the output. Valid values: CSV, JSON
--formatter=<customExporter>
Path to java file of a custom FlacocoExporter.
-h, --help Show this help message and exit.
--includeZeros Flag for including lines with a suspiciousness sore
of 0.
--jacocoClasspath=<customJacocoClasspath>
Classpath to jacoco dependencies.
--junitClasspath=<customJUnitClasspath>
Classpath to junit dependencies.
--mavenHome=<mavenHome>
Path to maven home.
-o, --output[=<output>] Path to the output file. If no path is provided but
the flag is, the result will be stored in
flacoco_result.{extension}
-p, --projectpath=<projectPath>
Path to the project to analyze.
--srcJavaDir[=<srcJavaDir>...]
Paths to the directories containing java source
files. Defaults to {projectpath}/src/main/java
--srcTestDir[=<srcTestDir>...]
Paths to the directories containing java test
source files. Defaults to {projectpath}/src/test
--testRunnerJVMArgs=<testRunnerJVMArgs>
JVM args for test-runner's test execution VMs.
--testRunnerTimeoutInMs=<testRunnerTimeoutInMs>
Timeout for each test execution with test-runner.
Must be greater than 0. Default value is 1000000
--testRunnerVerbose Test-runner verbose mode.
--threshold=<threshold>
Threshold for suspiciousness score. Flacoco will
only return suspicious results with score >=
threshold. Results with a score of 0 are only
included if the -includeZeros flag is set.
-v Verbose mode.
-V, --version Print version information and exit.
-w, --workspace=<workspace>
Path to the workspace directory of flacoco.
Setting any of these options will result in test detection being bypassed.
--junit4tests=<jUnit4Tests>
JUnit4 or JUnit3 tests to be ran.
--junit5tests=<jUnit5Tests>
JUnit5 tests to be ran.
Custom FlacocoExporter
If the exporting options do not fit your needs, you can write your own FlacocoExporter
and pass it to flacoco
in runtime.
For example, below, we have implemented OneLineExporter
, a FlacocoExporter
implementation that writes the results all in one line:
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Map;
public class OneLineExporter implements fr.spoonlabs.flacoco.cli.export.FlacocoExporter {
@Override
public void export(Map<String, fr.spoonlabs.flacoco.api.Suspiciousness> results, OutputStreamWriter outputStream) throws IOException {
for (Map.Entry<String, fr.spoonlabs.flacoco.api.Suspiciousness> entry : results.entrySet()) {
outputStream.write(entry.getKey() + "," + entry.getValue().getScore());
}
}
@Override
public String extension() {
return "custom";
}
}
To use this formatter in runtime, we can simply provide the path to the .java
file to flacoco
:
java -jar target/flacoco-0.0.1-SNAPSHOT-jar-with-dependencies.jar -p "examples/exampleFL1/FLtest1/" --formatter "src/test/resources/OneLineExporter.java"