-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
junit5: pass static nested classes to the launcher (#195)
This change iterates over all the static nested classes of the test class and adds them to LauncherDiscoveryRequestBuilder to allow running tests within static nested classes. While Java allows more than one level of nesting, we limit our search to one level of nesting at the moment. Junit4 tests annotated with `RunWith(Enclosed.class)` need to be special cased. Refer: gradle/gradle#4427
- Loading branch information
1 parent
0ce5d05
commit d82900b
Showing
4 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/NestedClassesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.bazel_contrib.contrib_rules_jvm.junit5; | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class NestedClassesTest { | ||
static class First { | ||
@Test | ||
public void shouldBeExecuted() { | ||
System.out.println(">>>> Executed test in NestedClassesTest$First"); | ||
} | ||
} | ||
|
||
@Nested | ||
@SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC") | ||
class Second { | ||
@Test | ||
public void shouldBeExecuted() { | ||
System.out.println(">>>> Executed test in NestedClassesTest$Second"); | ||
} | ||
} | ||
|
||
@Test | ||
public void shouldBeExecuted() { | ||
System.out.println(">>>> Executed test in NestedClassesTest"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/NestedClassesVintageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.bazel_contrib.contrib_rules_jvm.junit5; | ||
|
||
import org.junit.Test; | ||
import org.junit.experimental.runners.Enclosed; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Enclosed.class) | ||
public class NestedClassesVintageTest { | ||
public static class First { | ||
@Test | ||
public void shouldBeExecuted() { | ||
System.out.println(">>>> Executed test in NestedClassesVintageTest$First"); | ||
} | ||
} | ||
} |