SimpleTestClassModel: add deep field
This commit is contained in:
+9
-5
@@ -33,6 +33,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
private final String doTestMethodName;
|
private final String doTestMethodName;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String testClassName;
|
private final String testClassName;
|
||||||
|
private final Integer deep;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final TargetBackend targetBackend;
|
private final TargetBackend targetBackend;
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -56,7 +57,8 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
@NotNull TargetBackend targetBackend,
|
@NotNull TargetBackend targetBackend,
|
||||||
@NotNull Collection<String> excludeDirs,
|
@NotNull Collection<String> excludeDirs,
|
||||||
boolean skipIgnored,
|
boolean skipIgnored,
|
||||||
String testRunnerMethodName
|
String testRunnerMethodName,
|
||||||
|
Integer deep
|
||||||
) {
|
) {
|
||||||
this.rootFile = rootFile;
|
this.rootFile = rootFile;
|
||||||
this.recursive = recursive;
|
this.recursive = recursive;
|
||||||
@@ -69,12 +71,13 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
this.excludeDirs = excludeDirs.isEmpty() ? Collections.emptySet() : new LinkedHashSet<>(excludeDirs);
|
this.excludeDirs = excludeDirs.isEmpty() ? Collections.emptySet() : new LinkedHashSet<>(excludeDirs);
|
||||||
this.skipIgnored = skipIgnored;
|
this.skipIgnored = skipIgnored;
|
||||||
this.testRunnerMethodName = testRunnerMethodName;
|
this.testRunnerMethodName = testRunnerMethodName;
|
||||||
|
this.deep = deep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<TestClassModel> getInnerTestClasses() {
|
public Collection<TestClassModel> getInnerTestClasses() {
|
||||||
if (!rootFile.isDirectory() || !recursive) {
|
if (!rootFile.isDirectory() || !recursive || deep != null && deep < 1) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +91,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
children.add(new SimpleTestClassModel(
|
children.add(new SimpleTestClassModel(
|
||||||
file, true, excludeParentDirs, filenamePattern, checkFilenameStartsLowerCase,
|
file, true, excludeParentDirs, filenamePattern, checkFilenameStartsLowerCase,
|
||||||
doTestMethodName, innerTestClassName, targetBackend, excludesStripOneDirectory(file.getName()),
|
doTestMethodName, innerTestClassName, targetBackend, excludesStripOneDirectory(file.getName()),
|
||||||
skipIgnored, testRunnerMethodName)
|
skipIgnored, testRunnerMethodName, deep != null ? deep - 1 : null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,7 +161,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
|
|
||||||
boolean hasCoroutines = false;
|
boolean hasCoroutines = false;
|
||||||
|
|
||||||
if (listFiles != null) {
|
if (listFiles != null && (deep == null || deep == 0)) {
|
||||||
for (File file : listFiles) {
|
for (File file : listFiles) {
|
||||||
if (filenamePattern.matcher(file.getName()).matches()) {
|
if (filenamePattern.matcher(file.getName()).matches()) {
|
||||||
|
|
||||||
@@ -234,7 +237,8 @@ public class SimpleTestClassModel implements TestClassModel {
|
|||||||
}
|
}
|
||||||
String assertTestsPresentStr = String.format(
|
String assertTestsPresentStr = String.format(
|
||||||
"KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s.%s, %s%s);",
|
"KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File(\"%s\"), Pattern.compile(\"%s\"), %s.%s, %s%s);",
|
||||||
KotlinTestUtils.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()), TargetBackend.class.getSimpleName(), targetBackend.toString(), recursive, exclude
|
KotlinTestUtils.getFilePath(rootFile), StringUtil.escapeStringCharacters(filenamePattern.pattern()),
|
||||||
|
TargetBackend.class.getSimpleName(), targetBackend.toString(), recursive, exclude
|
||||||
);
|
);
|
||||||
p.println(assertTestsPresentStr);
|
p.println(assertTestsPresentStr);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -47,7 +47,8 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes
|
|||||||
targetBackend: TargetBackend = TargetBackend.ANY,
|
targetBackend: TargetBackend = TargetBackend.ANY,
|
||||||
excludeDirs: List<String> = listOf(),
|
excludeDirs: List<String> = listOf(),
|
||||||
filenameStartsLowerCase: Boolean? = null,
|
filenameStartsLowerCase: Boolean? = null,
|
||||||
skipIgnored: Boolean = false
|
skipIgnored: Boolean = false,
|
||||||
|
deep: Int? = null
|
||||||
) {
|
) {
|
||||||
val rootFile = File("$testDataRoot/$relativeRootPath")
|
val rootFile = File("$testDataRoot/$relativeRootPath")
|
||||||
val compiledPattern = Pattern.compile(pattern)
|
val compiledPattern = Pattern.compile(pattern)
|
||||||
@@ -63,7 +64,7 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes
|
|||||||
SimpleTestClassModel(
|
SimpleTestClassModel(
|
||||||
rootFile, recursive, excludeParentDirs,
|
rootFile, recursive, excludeParentDirs,
|
||||||
compiledPattern, filenameStartsLowerCase, testMethod, className,
|
compiledPattern, filenameStartsLowerCase, testMethod, className,
|
||||||
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName
|
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, deep
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user