Don't generate test when target backend is not suitable
This commit is contained in:
+5
@@ -234,5 +234,10 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
public void generateSignature(@NotNull Printer p) {
|
||||
TestMethodModel.DefaultImpls.generateSignature(this, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -117,7 +117,8 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldBeGenerated() {
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
if (targetBackend == TargetBackend.ANY) return true;
|
||||
|
||||
List<String> backends = InTextDirectivesUtils.findLinesWithPrefixesRemoved(textWithDirectives(), "// TARGET_BACKEND: ");
|
||||
@@ -149,7 +150,7 @@ public class SimpleTestMethodModel implements TestMethodModel {
|
||||
String relativePath = FileUtil.getRelativePath(rootDir, file.getParentFile());
|
||||
unescapedName = relativePath + "-" + StringUtil.capitalize(extractedName);
|
||||
}
|
||||
return (!shouldBeGenerated() ? "ignored" : "test") + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
|
||||
return "test" + StringUtil.capitalize(TestGeneratorUtil.escapeForJavaIdentifier(unescapedName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -160,5 +160,10 @@ public class SingleClassTestModel implements TestClassModel {
|
||||
public void generateSignature(@NotNull Printer p) {
|
||||
TestMethodModel.DefaultImpls.generateSignature(this, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeGenerated() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,9 @@ public class TestGenerator {
|
||||
|
||||
for (Iterator<MethodModel> iterator = testMethods.iterator(); iterator.hasNext(); ) {
|
||||
MethodModel methodModel = iterator.next();
|
||||
|
||||
if (!methodModel.shouldBeGenerated()) continue;
|
||||
|
||||
generateTestMethod(p, methodModel);
|
||||
if (iterator.hasNext() || !innerTestClasses.isEmpty()) {
|
||||
p.println();
|
||||
|
||||
@@ -31,6 +31,7 @@ interface TestClassModel : TestEntityModel {
|
||||
}
|
||||
|
||||
interface MethodModel : TestEntityModel {
|
||||
fun shouldBeGenerated(): Boolean = true
|
||||
fun generateSignature(p: Printer)
|
||||
fun generateBody(p: Printer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user