Added test for all parameters
This commit is contained in:
parent
61c200ee54
commit
6fa52100ec
4 changed files with 71 additions and 16 deletions
|
@ -34,7 +34,7 @@ public class DetektOperationBuild extends Project {
|
|||
public DetektOperationBuild() {
|
||||
pkg = "rife.bld.extension";
|
||||
name = "DetektOperation";
|
||||
version = version(0, 9, 4);
|
||||
version = version(0, 9, 5, "SNAPSHOT");
|
||||
|
||||
javaRelease = 17;
|
||||
downloadSources = true;
|
||||
|
|
|
@ -402,7 +402,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
|||
// report
|
||||
if (!report_.isEmpty()) {
|
||||
report_.forEach(it -> {
|
||||
args.add("-r");
|
||||
args.add("--report");
|
||||
args.add(it.id().name().toLowerCase() + ":" + it.path());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package rife.bld.extension;
|
|||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.BaseProject;
|
||||
import rife.bld.blueprints.BaseProjectBlueprint;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
|
||||
|
@ -57,6 +58,74 @@ class DetektOperationTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckAllParameters() {
|
||||
var params = List.of(
|
||||
"--all-rules",
|
||||
"--auto-correct",
|
||||
"--base-path",
|
||||
"--baseline",
|
||||
"--build-upon-default-config",
|
||||
"--classpath",
|
||||
"--config",
|
||||
"--config-resource",
|
||||
"--create-baseline",
|
||||
"--debug",
|
||||
"--disable-default-rulesets",
|
||||
"--excludes",
|
||||
"--generate-config",
|
||||
"--includes",
|
||||
"--input",
|
||||
"--jdk-home",
|
||||
"--jvm-target",
|
||||
"--language-version",
|
||||
"--max-issues",
|
||||
"--parallel",
|
||||
"--plugins",
|
||||
"--report"
|
||||
);
|
||||
|
||||
var args = new DetektOperation()
|
||||
.fromProject(new BaseProject())
|
||||
.allRules(true)
|
||||
.autoCorrect(true)
|
||||
.basePath("basePath")
|
||||
.baseline("baseline")
|
||||
.buildUponDefaultConfig(true)
|
||||
.classPath("classpath")
|
||||
.classPath(List.of("path2", "path3"))
|
||||
.config("config")
|
||||
.config(List.of("config2", "config4"))
|
||||
.configResource("configResource")
|
||||
.createBaseline(true)
|
||||
.debug(true)
|
||||
.disableDefaultRuleSets(true)
|
||||
.excludes("excludes")
|
||||
.generateConfig(true)
|
||||
.includes("patterns")
|
||||
.input("input")
|
||||
.jdkHome("jdkHome")
|
||||
.jvmTarget("jvmTarget")
|
||||
.languageVersion("languageVersion")
|
||||
.maxIssues(10)
|
||||
.parallel(true)
|
||||
.plugins("jars")
|
||||
.plugins(List.of("jars2", "jar3"))
|
||||
.report(new DetektReport(DetektReportId.HTML, "reports"))
|
||||
.executeConstructProcessCommandList();
|
||||
|
||||
for (var p : params) {
|
||||
var found = false;
|
||||
for (var a : args) {
|
||||
if (a.startsWith(p)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertThat(found).as(p + " not found.").isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExampleBaseline() throws IOException, ExitStatusException, InterruptedException {
|
||||
var tmpDir = Files.createTempDirectory("bld-detekt-").toFile();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue