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

Development: Fix mockito warning #10327

Merged
merged 1 commit into from
Feb 15, 2025
Merged

Development: Fix mockito warning #10327

merged 1 commit into from
Feb 15, 2025

Conversation

tobias-lippert
Copy link
Contributor

@tobias-lippert tobias-lippert commented Feb 14, 2025

Checklist

General

Motivation and Context

Closes #10154
Mockito logs a warning at the beginning of the server test execution that it currently self-attaches to the inline-mock-maker and this might no longer work in the future.

Description

Followed the steps described here.
Had to change the order when test.gradle is applied in build.gradle to make the gradle build still compile.

Steps for Testing

Run the server tests locally or check the logs on Github/Bamboo.
Check that the server test logs no longer contain the following text
Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK
Code Review

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

  • Chores

    • Revised the build configuration to streamline dependency management and eliminate resolution issues.
    • Phased out outdated dependency settings in favor of a more robust setup.
  • Tests

    • Enhanced the testing environment by integrating improved support for mocking, leading to more reliable test executions.

@tobias-lippert tobias-lippert requested a review from a team as a code owner February 14, 2025 19:45
@@ -80,7 +79,7 @@ modernizer {
}

configurations {
providedRuntime
Copy link
Contributor Author

Choose a reason for hiding this comment

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

providedRuntime isn't used anywhere.

Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

The pull request modifies the Gradle build configuration to address dependency resolution errors. In build.gradle, the application of test.gradle is moved after the dependencies block along with an explanatory comment. Additionally, a new configuration named mockitoAgent is added (including the mockito-core dependency without transitive dependencies), and the providedRuntime configuration is removed. In gradle/test.gradle, a new JVM argument is appended to the test tasks to enable the Mockito Java agent.

Changes

Files Change Summary
build.gradle Moved the application of test.gradle after the dependencies block with a comment; introduced new configuration mockitoAgent (with mockito-core without transitive deps); removed providedRuntime.
gradle/test.gradle Added a new JVM argument (-javaagent:${configurations.mockitoAgent.asPath}) within the test tasks to integrate the Mockito agent.

Sequence Diagram(s)

sequenceDiagram
    participant Build as Build System
    participant TestTask as Test Task Executor
    participant MockitoAgent as Mockito Agent Config
    Build->>Build: Apply dependencies (build.gradle)
    Build->>Build: Apply test configuration (test.gradle) after dependencies
    TestTask->>MockitoAgent: Retrieve Mockito agent classpath from `mockitoAgent`
    TestTask->>TestTask: Add JVM argument "-javaagent:<mockitoAgent path>"
    TestTask->>Build: Execute tests with enhanced Mockito support
Loading

Possibly related PRs

Suggested labels

chore, tests, ready for review

Suggested reviewers

  • krusche
  • SimonEntholzer
  • HanyangXu0508

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cd17b5 and dc29cf1.

📒 Files selected for processing (2)
  • build.gradle (3 hunks)
  • gradle/test.gradle (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: server-tests
  • GitHub Check: Gradle Wrapper Validation
  • GitHub Check: Analyse
🔇 Additional comments (4)
gradle/test.gradle (1)

5-8: Mockito Java Agent Integration:
The JVM argument added with

jvmArgs += "-javaagent:${configurations.mockitoAgent.asPath}"

ensures that the Mockito agent is attached at test runtime, which should resolve the self-attaching warning noted in the PR objective. Make sure that the corresponding mockitoAgent configuration (defined in build.gradle) is always set up before this script is executed.

build.gradle (3)

81-83: Mockito Agent Configuration Addition:
A new configuration named mockitoAgent has been introduced. This configuration will serve to hold the Mockito agent dependency, which is later referenced by the test tasks via the JVM argument.


420-423: Mockito Agent Dependency Declaration:
Adding the Mockito dependency under the mockitoAgent configuration with transitive = false is a good move to isolate the dependency solely for the agent purposes. This helps to avoid including unwanted transitive dependencies and minimizes conflicts.


447-449: Reordering of Test Script Application:
Moving the application of gradle/test.gradle to after the dependencies block is essential to prevent errors related to resolving the mockitoAgent configuration. This change adheres to Gradle’s dependency resolution order and eliminates the "Cannot change dependencies..." error.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@krusche krusche changed the title Development: Fix Mockito warning Development: Fix mockito warning Feb 15, 2025
@krusche krusche added this to the 7.10.1 milestone Feb 15, 2025
@krusche krusche merged commit 3fb2666 into develop Feb 15, 2025
31 of 33 checks passed
@krusche krusche deleted the chore/mockito-agent-fix branch February 15, 2025 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Add Mockito as agent
2 participants