Skip to content

Fixes #3709: Add GraalVM nativeTest test suite#3714

Closed
phipag wants to merge 10 commits intomockito:mainfrom
phipag:graalvm-test-suite
Closed

Fixes #3709: Add GraalVM nativeTest test suite#3714
phipag wants to merge 10 commits intomockito:mainfrom
phipag:graalvm-test-suite

Conversation

@phipag
Copy link
Copy Markdown
Contributor

@phipag phipag commented Aug 21, 2025

Description

Adds a test suite using the subclass MockMaker running a simple Mockito test using GraalVM native image. Tested using 21.0.8-graal.

Run:

sdk use java 21.0.8-graal
./gradlew :mockito-integration-tests:graalvm-tests:nativeTestWithMetadata 

After merging #3710 the reflect-config.json should include a line similar to this:

{
  "name":"org.mockito.internal.creation.bytebuddy.codegen.DummyObject$MockitoMock$je9a223op99200N"
},

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style (run ./gradlew spotlessApply for auto-formatting)
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should end with Fixes #<issue number> if relevant

@phipag phipag mentioned this pull request Aug 21, 2025
@phipag
Copy link
Copy Markdown
Contributor Author

phipag commented Aug 21, 2025

This PR is ready for review now. I tested the GraalVM job in my fork: https://github.com/phipag/mockito/actions/runs/17128459949.

It fails as expected and should succeed after merging #3710

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.43%. Comparing base (ef2fd6f) to head (d380ed1).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #3714   +/-   ##
=========================================
  Coverage     86.43%   86.43%           
  Complexity     2969     2969           
=========================================
  Files           341      341           
  Lines          9011     9011           
  Branches       1110     1110           
=========================================
  Hits           7789     7789           
  Misses          941      941           
  Partials        281      281           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@phipag
Copy link
Copy Markdown
Contributor Author

phipag commented Aug 21, 2025

I see the JVM tests fail now with:

> Task :mockito-integration-tests:graalvm-tests:test FAILED
[native-image-plugin] Instrumenting task with the native-image-agent: test


Error occurred during initialization of VM
Could not find agent library native-image-agent on the library path, with error: libnative-image-agent.so: cannot open shared object file: No such file or directory

  0 passing (61ms)

I should fix that the tests still work when using JVM and not GraalVM in the environment.

@phipag
Copy link
Copy Markdown
Contributor Author

phipag commented Aug 21, 2025

I added a potential fix in a347ff3. Let's see if this is enough to conditionally enable the tracing agent.

@phipag
Copy link
Copy Markdown
Contributor Author

phipag commented Aug 21, 2025

The CI shows the expected result now:

DummyObject mock not found in reflect-config.json
Error: Process completed with exit code 1.

After merging and rebasing on #3710 we should see the graalvm workflow succeeding as well.

@TimvdLippe
Copy link
Copy Markdown
Contributor

This landed with #3710

@TimvdLippe TimvdLippe closed this Sep 19, 2025
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.

3 participants