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

KAFKA-18356 Explicitly setting up instrumentation for inline mocking (Java 21+) #18339

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,27 @@ subprojects {
}
}

afterEvaluate { subproject ->
def hasMockitoCore = subproject.configurations.findAll {
it.canBeResolved
}.any { config ->
config.incoming.dependencies.any { dependency ->
"${dependency.group}:${dependency.name}" == "org.mockito:mockito-core"
}
}

if (hasMockitoCore) {
subproject.configurations {
mockitoAgent {
transitive = false
}
}
subproject.dependencies {
mockitoAgent libs.mockitoCore
}
}
}

// The suites are for running sets of tests in IDEs.
// Gradle will run each test class, so we exclude the suites to avoid redundantly running the tests twice.
def testsToExclude = ['**/*Suite.class']
Expand All @@ -486,6 +507,10 @@ subprojects {
isGithubActions = System.getenv('GITHUB_ACTIONS') != null
hadFailure = false // Used to track if any tests failed, see afterSuite below
}

doFirst {
jvmArgs("-javaagent:${configurations.mockitoAgent.asPath}")
}

maxParallelForks = maxTestForks
ignoreFailures = userIgnoreFailures || ext.isGithubActions
Expand Down
Loading