-
Notifications
You must be signed in to change notification settings - Fork 2
[DiscoveryTestClassesTask] Task that discovers testClasses in spock and junit-jupiter test engines #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-testing into cr/discover-tests
Generate changelog in
|
✅ Successfully generated changelog entry!Need to regenerate?Simply interact with the changelog bot comment again to regenerate these entries. 📋Changelog Preview💡 Improvements
|
discover-tests-cli/src/main/java/com/palantir/gradle/plugintesting/SubClassesOfCommand.java
Outdated
Show resolved
Hide resolved
...plugin-testing/src/main/java/com/palantir/gradle/plugintesting/DiscoveryTestClassesTask.java
Outdated
Show resolved
Hide resolved
...-plugin-testing/src/main/java/com/palantir/gradle/plugintesting/DiscoverTestClassesTask.java
Show resolved
Hide resolved
...plugin-testing/src/main/java/com/palantir/gradle/plugintesting/DiscoveryTestClassesTask.java
Outdated
Show resolved
Hide resolved
...-plugin-testing/src/main/java/com/palantir/gradle/plugintesting/DiscoverTestClassesTask.java
Show resolved
Hide resolved
...in-testing/src/test/java/com/palantir/gradle/plugintesting/PluginTestingJunitPluginTest.java
Show resolved
Hide resolved
...in-testing/src/test/java/com/palantir/gradle/plugintesting/PluginTestingJunitPluginTest.java
Outdated
Show resolved
Hide resolved
discover-tests-cli/src/main/java/com/palantir/gradle/plugintesting/TestClassesDiscoverer.java
Show resolved
Hide resolved
discover-tests-cli/src/main/java/com/palantir/gradle/plugintesting/TestClassesDiscoverer.java
Outdated
Show resolved
Hide resolved
discover-tests-cli/src/main/java/com/palantir/gradle/plugintesting/TestClassesDiscoverer.java
Outdated
Show resolved
Hide resolved
...in-testing/src/test/java/com/palantir/gradle/plugintesting/PluginTestingJunitPluginTest.java
Outdated
Show resolved
Hide resolved
...in-testing/src/test/java/com/palantir/gradle/plugintesting/PluginTestingJunitPluginTest.java
Outdated
Show resolved
Hide resolved
| .assertThat() | ||
| .content() | ||
| .isEqualTo("src/test/java/test/GradlePluginTestClass.java"); | ||
| assertThat(Files.readAllLines(rootProject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's make a static method for:
Files.readAllLines(rootProject.buildDir().directory("tests-discovery/java").file("test-classes-paths").path());e.g. readTestClassesPaths or something
| @Option(names = "--include", split = ",", description = "List of subClasses to include") | ||
| private List<String> subClasses; | ||
| private List<String> classNames; | ||
|
|
||
| @Option(names = "--exclude", split = ",", description = "List of subClasses to exclude") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's update the description with the new change
| return annotations.stream().anyMatch(annotation -> hasClassAnnotation(clazz, annotation)); | ||
| } | ||
|
|
||
| private static boolean hasClassAnnotation(Class<?> clazz, String annotationName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something I forgot to mention the first time. We should use AnnotationSupport#isAnnotated it's in the junit-platform-commons jar
|
|
||
| @Override | ||
| protected Filter<?> getFilter() { | ||
| return new PostDiscoveryFilter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we convert the list of includedAnnotations to List<Class<? extends Annotation>> here, and then reference that below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we won't pay the cost of loading the class each time, since it's cached within the classloader, but there's still a bit of code around that which scales with the number of tests a project has.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to just filter here rather than throw? then you don't fail when you try to run this command on a classpath that doesn't have the annotations you care about. That said, I'm not sure if it will happen in practice
…testing/PluginTestingJunitPluginTest.java Co-authored-by: Felix de Souza <[email protected]>
…-testing into cr/discover-tests
|
👍 let's gooo 🚀 |
|
Released 0.40.0 |
Before this PR
After this PR
FLUP for https://pl.ntr/2ye. We can now auto-discover the testClasesFiles in a repo using a
DiscoveryTestClassesTasktask. Introducing 2 tasks:discoverGradlePluginTestsdiscovers GradlePluginTests annotated test classes. This will be used by the Configuration cache enablement migration to discover the tests that need to be annotated with@DisabledConfigurationCache.discoverNebulaTestClassesToMigratediscovers the groovy test classes that extendIntegrationSpec,IntegrationTeskKitSpecexcluding theConfigurationCacheSpectests. This will be used by the excavator to discover the groovy tests that need to be migrated to the new junit framework.==COMMIT_MSG==
[DiscoveryTestClassesTask] Task that discovers testClasses in spock and junit-jupiter test engines
==COMMIT_MSG==
Possible downsides?