@@ -569,21 +569,23 @@ private DiscoveryResult discoverTestClasses() {
569
569
//for now this is out of scope, we are just going to do annotation based discovery
570
570
//we will need to fix this sooner rather than later though
571
571
572
+ if (moduleInfo .getTest ().isEmpty ()) {
573
+ return DiscoveryResult .EMPTY ;
574
+ }
575
+
572
576
//we also only run tests from the current module, which we can also revisit later
573
577
Indexer indexer = new Indexer ();
574
- moduleInfo .getTest ().ifPresent (test -> {
575
- try (Stream <Path > files = Files .walk (Paths .get (test .getClassesPath ()))) {
576
- files .filter (s -> s .getFileName ().toString ().endsWith (".class" )).forEach (s -> {
577
- try (InputStream in = Files .newInputStream (s )) {
578
- indexer .index (in );
579
- } catch (IOException e ) {
580
- throw new RuntimeException (e );
581
- }
582
- });
583
- } catch (IOException e ) {
584
- throw new RuntimeException (e );
585
- }
586
- });
578
+ try (Stream <Path > files = Files .walk (Paths .get (moduleInfo .getTest ().get ().getClassesPath ()))) {
579
+ files .filter (s -> s .getFileName ().toString ().endsWith (".class" )).forEach (s -> {
580
+ try (InputStream in = Files .newInputStream (s )) {
581
+ indexer .index (in );
582
+ } catch (IOException e ) {
583
+ throw new RuntimeException (e );
584
+ }
585
+ });
586
+ } catch (IOException e ) {
587
+ throw new RuntimeException (e );
588
+ }
587
589
588
590
Index index = indexer .complete ();
589
591
//we now have all the classes by name
@@ -699,6 +701,20 @@ private DiscoveryResult discoverTestClasses() {
699
701
unitTestClasses .add (name );
700
702
}
701
703
704
+ // if we didn't find any test classes, let's return early
705
+ // Make sure you also update the logic for the non-empty case above if you adjust this part
706
+ if (testType == TestType .ALL ) {
707
+ if (unitTestClasses .isEmpty () && quarkusTestClasses .isEmpty ()) {
708
+ return DiscoveryResult .EMPTY ;
709
+ }
710
+ } else if (testType == TestType .UNIT ) {
711
+ if (unitTestClasses .isEmpty ()) {
712
+ return DiscoveryResult .EMPTY ;
713
+ }
714
+ } else if (quarkusTestClasses .isEmpty ()) {
715
+ return DiscoveryResult .EMPTY ;
716
+ }
717
+
702
718
List <Class <?>> itClasses = new ArrayList <>();
703
719
List <Class <?>> utClasses = new ArrayList <>();
704
720
@@ -809,6 +825,7 @@ public String apply(Class<?> aClass) {
809
825
}
810
826
}
811
827
828
+ // Make sure you also update the logic for the empty case above if you adjust this part
812
829
if (testType == TestType .ALL ) {
813
830
//run unit style tests first
814
831
//before the quarkus tests have started
@@ -1271,6 +1288,8 @@ public FilterResult apply(TestDescriptor testDescriptor) {
1271
1288
1272
1289
static class DiscoveryResult implements AutoCloseable {
1273
1290
1291
+ private final static DiscoveryResult EMPTY = new DiscoveryResult (null , List .of ());
1292
+
1274
1293
final QuarkusClassLoader classLoader ;
1275
1294
final List <Class <?>> testClasses ;
1276
1295
0 commit comments