Add test tool options
This commit is contained in:
parent
35f41fb681
commit
88bda60551
2 changed files with 133 additions and 0 deletions
|
@ -61,6 +61,10 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
* The location of the source files.
|
||||
*/
|
||||
final private Collection<File> sourceFiles_ = new ArrayList<>();
|
||||
/**
|
||||
* The test tool options.
|
||||
*/
|
||||
final private Collection<String> testToolOptions_ = new ArrayList<>();
|
||||
/**
|
||||
* The location of the CSV report.
|
||||
*/
|
||||
|
@ -212,6 +216,15 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return csv(csv.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CSV report location.
|
||||
*
|
||||
* @return the CSV report location
|
||||
*/
|
||||
public File csv() {
|
||||
return csv_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file to write execution data to.
|
||||
*
|
||||
|
@ -243,6 +256,15 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return destFile(destFile.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file to write execution data to.
|
||||
*
|
||||
* @return the file to write execution data to
|
||||
*/
|
||||
public File destFile() {
|
||||
return destFile_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source file encoding. The platform encoding is used by default.
|
||||
*
|
||||
|
@ -254,6 +276,15 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source file encoding.
|
||||
*
|
||||
* @return the source file encoding
|
||||
*/
|
||||
public String encoding() {
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locations of the JaCoCo *.exec files to read.
|
||||
*
|
||||
|
@ -356,6 +387,10 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
"org.jacoco.agent-" + JaCoCo.VERSION.substring(0, JaCoCo.VERSION.lastIndexOf('.'))
|
||||
+ "-runtime.jar").toFile(), "destfile=" + destFile_.getPath());
|
||||
|
||||
if (!testToolOptions_.isEmpty()) {
|
||||
testOperation.testToolOptions().addAll(testToolOptions_);
|
||||
}
|
||||
|
||||
testOperation.execute();
|
||||
|
||||
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
||||
|
@ -439,6 +474,24 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return html(html.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML report location.
|
||||
*
|
||||
* @return the HTML report location
|
||||
*/
|
||||
public File html() {
|
||||
return html_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the status of the quiet flag.
|
||||
*
|
||||
* @return {@code true} if enabled, {@code false} otherwise
|
||||
*/
|
||||
public boolean isQuiet() {
|
||||
return silent();
|
||||
}
|
||||
|
||||
private ExecFileLoader loadExecFiles() throws IOException {
|
||||
var loader = new ExecFileLoader();
|
||||
if (execFiles_.isEmpty() && LOGGER.isLoggable(Level.WARNING) && !silent()) {
|
||||
|
@ -466,6 +519,15 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name used for the report.
|
||||
*
|
||||
* @return the report name.
|
||||
*/
|
||||
public String name() {
|
||||
return reportName_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppresses all output.
|
||||
*
|
||||
|
@ -594,6 +656,47 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tab stop width for the source pages.
|
||||
*
|
||||
* @return the tab stop width
|
||||
*/
|
||||
public int tabWidth() {
|
||||
return tabWidth_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the test tool options.
|
||||
*
|
||||
* @return the test tool options
|
||||
*/
|
||||
public Collection<String> testToolOptions() {
|
||||
return testToolOptions_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the test tool options.
|
||||
*
|
||||
* @param options The options to set
|
||||
* @return this operation instance
|
||||
* @see #testToolOptions(Collection)
|
||||
*/
|
||||
public JacocoReportOperation testToolOptions(String... options) {
|
||||
return testToolOptions(List.of(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the test tool options.
|
||||
*
|
||||
* @param options The options to set
|
||||
* @return this operation instance
|
||||
* @see #testToolOptions(String...)
|
||||
*/
|
||||
public JacocoReportOperation testToolOptions(Collection<String> options) {
|
||||
testToolOptions_.addAll(options);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void writeReports(IBundleCoverage bundle, ExecFileLoader loader)
|
||||
throws IOException {
|
||||
if (LOGGER.isLoggable(Level.INFO) && !silent()) {
|
||||
|
@ -642,4 +745,13 @@ public class JacocoReportOperation extends AbstractOperation<JacocoReportOperati
|
|||
public JacocoReportOperation xml(Path xml) {
|
||||
return xml(xml.toFile());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML report location.
|
||||
*
|
||||
* @return the XML report location
|
||||
*/
|
||||
public File xml() {
|
||||
return xml_;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ class JacocoReportOperationTest {
|
|||
}
|
||||
|
||||
|
||||
@Nested
|
||||
@DisplayName("Options Tests")
|
||||
class OptionsTests {
|
||||
public static final String FOO = "foo";
|
||||
|
@ -221,6 +222,26 @@ class JacocoReportOperationTest {
|
|||
op.xml(FOO);
|
||||
assertThat(op.xml()).isEqualTo(fooFile);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Test Tool Options Tests")
|
||||
class TestToolOptionsTests {
|
||||
public static final String BAR = "bar";
|
||||
|
||||
@Test
|
||||
void testToolOptionsAsArray() {
|
||||
var op = new JacocoReportOperation();
|
||||
op = op.testToolOptions(FOO, BAR);
|
||||
assertThat(op.testToolOptions()).contains(FOO, BAR);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToolOptionsAsList() {
|
||||
var op = new JacocoReportOperation();
|
||||
op.testToolOptions(List.of(FOO, BAR));
|
||||
assertThat(op.testToolOptions()).contains(FOO, BAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue