SimpleTestClassModel: add deep field

This commit is contained in:
Dmitry Gridin
2019-08-19 20:09:48 +07:00
parent 65ce4aed1a
commit 02fd137cec
2 changed files with 12 additions and 7 deletions
@@ -33,6 +33,7 @@ public class SimpleTestClassModel implements TestClassModel {
private final String doTestMethodName;
@NotNull
private final String testClassName;
private final Integer deep;
@NotNull
private final TargetBackend targetBackend;
@NotNull
@@ -56,7 +57,8 @@ public class SimpleTestClassModel implements TestClassModel {
@NotNull TargetBackend targetBackend,
@NotNull Collection<String> excludeDirs,
boolean skipIgnored,
String testRunnerMethodName
String testRunnerMethodName,
Integer deep
) {
this.rootFile = rootFile;
this.recursive = recursive;
@@ -69,12 +71,13 @@ public class SimpleTestClassModel implements TestClassModel {
this.excludeDirs = excludeDirs.isEmpty() ? Collections.emptySet() : new LinkedHashSet<>(excludeDirs);
this.skipIgnored = skipIgnored;
this.testRunnerMethodName = testRunnerMethodName;
this.deep = deep;
}
@NotNull
@Override
public Collection<TestClassModel> getInnerTestClasses() {
if (!rootFile.isDirectory() || !recursive) {
if (!rootFile.isDirectory() || !recursive || deep != null && deep < 1) {
return Collections.emptyList();
}
@@ -88,7 +91,7 @@ public class SimpleTestClassModel implements TestClassModel {
children.add(new SimpleTestClassModel(
file, true, excludeParentDirs, filenamePattern, checkFilenameStartsLowerCase,
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;
if (listFiles != null) {
if (listFiles != null && (deep == null || deep == 0)) {
for (File file : listFiles) {
if (filenamePattern.matcher(file.getName()).matches()) {
@@ -234,7 +237,8 @@ public class SimpleTestClassModel implements TestClassModel {
}
String assertTestsPresentStr = String.format(
"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);
}
@@ -47,7 +47,8 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes
targetBackend: TargetBackend = TargetBackend.ANY,
excludeDirs: List<String> = listOf(),
filenameStartsLowerCase: Boolean? = null,
skipIgnored: Boolean = false
skipIgnored: Boolean = false,
deep: Int? = null
) {
val rootFile = File("$testDataRoot/$relativeRootPath")
val compiledPattern = Pattern.compile(pattern)
@@ -63,7 +64,7 @@ class TestGroup(private val testsRoot: String, val testDataRoot: String, val tes
SimpleTestClassModel(
rootFile, recursive, excludeParentDirs,
compiledPattern, filenameStartsLowerCase, testMethod, className,
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName
targetBackend, excludeDirs, skipIgnored, testRunnerMethodName, deep
)
}
)