Skip to content
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

Add Upgrade Note for Strongly Typed Dependencies in Test Suites #22778

Merged
merged 9 commits into from Nov 17, 2022
Expand Up @@ -95,6 +95,7 @@ Common values are available as constants in link:{javadocPath}/org/gradle/api/at

Here are several examples to illustrate the configurability of test suites.

[[sec:declare_an_additional_test_suite]]
== Declare an additional test suite
====
include::sample[dir="snippets/testing/test-suite-plugin/groovy",files="build.gradle[tags=configure-testing-extension]"]
Expand Down
Expand Up @@ -117,6 +117,56 @@ PMD has been updated to https://pmd.github.io/pmd-6.48.0/pmd_release_notes.html[
When configuring an executable explicitly for link:{groovyDslPath}/org.gradle.api.tasks.compile.ForkOptions.html#org.gradle.api.tasks.compile.ForkOptions:executable[`JavaCompile`] or link:{groovyDslPath}/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:executable[`Test`] tasks, Gradle will now emit an error if this executable does not exist.
In the past, the task would be executed with the default toolchain or JVM running the build.

==== Strongly typed dependency declarations for Test Suites
tresat marked this conversation as resolved.
Show resolved Hide resolved

The `dependencies` block used to configure Test Suites and located at `testing.suites.<MY_SUITE_NAME>.dependencies` continues to diverge from the top-level `dependencies` block.
tresat marked this conversation as resolved.
Show resolved Hide resolved
This is part of an ongoing effort to improve this `@Incubating` API to make it more discoverable and strongly typed.
This change should have the benefit of making the `testing` DSL easier to work with in your IDE.
tresat marked this conversation as resolved.
Show resolved Hide resolved

On consequence of this is that buildsscripts which previously added project dependencies to a suite using:
tresat marked this conversation as resolved.
Show resolved Hide resolved

```kotlin
testing {
suites {
register<JvmTestSuite>("integrationTest") {
dependencies {
implementation(project)
}
}
}
}
```

will now fail to compile, with a message like:

```
None of the following functions can be called with the arguments supplied:
public operator fun DependencyAdder.invoke(dependencyNotation: CharSequence): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyAdder.invoke(dependency: Dependency): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyAdder.invoke(files: FileCollection): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyAdder.invoke(dependency: Provider<out Dependency>): Unit defined in org.gradle.kotlin.dsl
public operator fun DependencyAdder.invoke(externalModule: ProviderConvertible<out MinimalExternalModuleDependency>): Unit defined in org.gradle.kotlin.dsl
```

To fix this, replace the reference to `project` with a call to `project()`:

```kotlin
testing {
suites {
register<JvmTestSuite>("integrationTest") {
dependencies {
implementation(project())
}
}
}
}
```

There may be other breaking changes related to dependency declarations in this block.
tresat marked this conversation as resolved.
Show resolved Hide resolved
tresat marked this conversation as resolved.
Show resolved Hide resolved
For more information, see the updated <<jvm_test_suite_plugin.adoc#sec:declare_an_additional_test_suite, declare an additional test suite>> example in the JVM Test Suite Plugin section of the user guide, and the link:{groovyDslPath}/org.gradle.api.artifacts.dsl.DependencyAdder.html[`DependencyAdder`] page in the DSL reference.
tresat marked this conversation as resolved.
Show resolved Hide resolved
tresat marked this conversation as resolved.
Show resolved Hide resolved

```kotlin
tresat marked this conversation as resolved.
Show resolved Hide resolved

=== Deprecations

[[invalid_toolchain_specification_deprecation]]
Expand Down