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

fix: gradle mockitoAgent configuration should not be transitive #3454

Merged
main from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/main/java/org/mockito/Mockito.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@
* to function without an explicit setup to enable instrumentation, and the JVM will always display a warning.
*
* <p>
* To explicitly attach Mockito during test execution, the library's jar file needs to be specified as `-javaagent`
* To explicitly attach Mockito during test execution, the library's jar file needs to be specified as <code>-javaagent</code>
* as an argument to the executing JVM. To enable this in Gradle, the following example adds Mockito to all test
* tasks:
*
* <pre class="code"><code class="kotlin">
* val mockitoAgent = configurations.create("mockitoAgent")
* dependencies {
* mockitoAgent(libs.mockito)
* testImplementation(libs.mockito)
* mockitoAgent(libs.mockito) { isTransitive = false }
* }
* tasks {
* test {
Expand All @@ -192,6 +193,16 @@
* }
* </code></pre>
*
* Supposing <code>Mockito</code> is declared in the version catalog as the following
*
* <pre class="code"><code class="toml">
* [versions]
* mockito = "5.14.0"
*
* [libraries]
* mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
* </code></pre>
*
* To add Mockito as an agent to Maven's surefire plugin, the following configuration is needed:
*
* <pre class="code"><code class="xml">
Expand Down
Loading