Skip to content

Commit d99dd21

Browse files
committed
Skip abstract classes and interfaces via JavaParser
1 parent 1952c0a commit d99dd21

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

src/main/java/de/donnerbart/split/TestSplit.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,15 @@ public void run() throws Exception {
193193
final var compilationUnit = javaParser.parse(testPath).getResult().orElseThrow();
194194
final var declaration = compilationUnit.findFirst(ClassOrInterfaceDeclaration.class).orElseThrow();
195195
final var className = declaration.getFullyQualifiedName().orElseThrow();
196-
if (declaration.getAnnotations()
196+
if (declaration.isInterface()) {
197+
LOG.info("Skipping test interface {}", className);
198+
} else if (declaration.isAbstract()) {
199+
LOG.info("Skipping abstract test class {}", className);
200+
} else if (declaration.getAnnotations()
197201
.stream()
198202
.map(AnnotationExpr::getNameAsString)
199203
.anyMatch(SKIP_TEST_ANNOTATIONS::contains)) {
200-
LOG.info("Skipping disabled test {}", className);
204+
LOG.info("Skipping disabled test class {}", className);
201205
} else {
202206
classNames.add(className);
203207
}

src/main/java/de/donnerbart/split/TestSplitMain.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public static void main(final @Nullable String @NotNull [] args) throws Exceptio
2828
System.out.println("--split-index must lesser than --split-total");
2929
System.exit(1);
3030
}
31-
final var excludeGlob = arguments.excludeGlob != null ? arguments.excludeGlob : "**/*Abstract*";
3231
final var workingDirectory = arguments.workingDirectory != null ?
3332
arguments.workingDirectory.toAbsolutePath() :
3433
Paths.get(System.getProperty("user.dir")).toAbsolutePath();
@@ -44,7 +43,7 @@ public static void main(final @Nullable String @NotNull [] args) throws Exceptio
4443
final var testSplit = new TestSplit(arguments.splitIndex,
4544
arguments.splitTotal,
4645
arguments.glob,
47-
excludeGlob,
46+
arguments.excludeGlob,
4847
arguments.junitGlob,
4948
workingDirectory,
5049
arguments.debug,

src/test/java/de/donnerbart/split/TestSplitTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ void setUp() throws Exception {
4343
.resolve("donnerbart")
4444
.resolve("example");
4545
Files.createDirectories(projectFolder);
46+
copyResourceToTarget(projectFolder, "tests/BaseTest.java", "BaseTest.java", PERMISSIONS);
4647
copyResourceToTarget(projectFolder, "tests/DisabledTest.java", "DisabledTest.java", PERMISSIONS);
48+
copyResourceToTarget(projectFolder, "tests/InterfaceTest.java", "InterfaceTest.java", PERMISSIONS);
4749
copyResourceToTarget(projectFolder, "tests/FastTest.java", "FastTest.java", PERMISSIONS);
4850
copyResourceToTarget(projectFolder, "tests/NoTimingOneTest.java", "NoTimingOneTest.java", PERMISSIONS);
4951
copyResourceToTarget(projectFolder, "tests/NoTimingTwoTest.java", "NoTimingTwoTest.java", PERMISSIONS);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package de.donnerbart.example;
2+
3+
abstract class BaseTest {
4+
5+
abstract void implementableMethod();
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package de.donnerbart.example;
2+
3+
interface BaseTest {
4+
5+
void implementableMethod();
6+
}

0 commit comments

Comments
 (0)