Skip to content

Conversation

@crogoz
Copy link
Contributor

@crogoz crogoz commented Nov 19, 2025

Before this PR

After this PR

FLUP for https://pl.ntr/2ye. We can now auto-discover the testClasesFiles in a repo using a DiscoveryTestClassesTask task. Introducing 2 tasks:

  1. discoverGradlePluginTests discovers 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.
  2. discoverGroovyTestClassesToMigrate discovers the groovy test classes that extend IntegrationSpec, IntegrationTeskKitSpec excluding the ConfigurationCacheSpec tests. 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?

@changelog-app
Copy link

changelog-app bot commented Nov 19, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

[DiscoveryTestClassesTask] Task that discovers testClasses in spock and junit-jupiter test engines

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link

changelog-app bot commented Nov 19, 2025

Successfully generated changelog entry!

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.


📋Changelog Preview

💡 Improvements

  • [DiscoveryTestClassesTask] Task that discovers testClasses in spock and junit-jupiter test engines (#297)


project.getTasks().withType(DiscoveryTestClassesTask.class, task -> {
SourceSetContainer sourceSetContainer = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet testSourceSet = sourceSetContainer.getByName(SourceSet.TEST_SOURCE_SET_NAME);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to capture integrationTest as well? That said, there aren't that many of them internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this project is wiring in other places other sourceSets besides the test one. Should we add it as a FLUP ?

SourceSetContainer sourceSetContainer = project.getExtensions().getByType(SourceSetContainer.class);
SourceSet testSourceSet = sourceSetContainer.getByName(SourceSet.TEST_SOURCE_SET_NAME);
task.getTestClasspath().setFrom(testSourceSet.getRuntimeClasspath());
task.getRuntimeClasspath().setFrom(project.getConfigurations().getByName("runtimeClasspath"));
Copy link

@felixdesouza felixdesouza Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are you capturing the classes that are discover-tests-cli ?

I think it's a little weird to put the runtimeClasspath on here.

We should probably make a configuration that contains just the discovery-tests-cli module and union that with the test classpath.

We should probably lock it as well since we wouldn't want it to clash - although we can probably hold off on this part until we see any issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't need this anymore - as the "testImplementation" of the project already has the "discovery-tests-cli" here: https://github.com/palantir/gradle-plugin-testing/pull/297/files#diff-ca7ede7b34d2580d6fdb25b3707c5007eb08095357c26ab8c22bcb48236f2b85R232. Let me know if you prefer to have a separate config for this though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants