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

Digma makes my tests fail (Mockito) #81

Open
black-snow opened this issue Oct 27, 2023 · 3 comments
Open

Digma makes my tests fail (Mockito) #81

black-snow opened this issue Oct 27, 2023 · 3 comments

Comments

@black-snow
Copy link

Describe the bug
I started with a green test suite.
I installed digma and ran the test suite.
Some tests suddenly fail with:

org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class de.workxl.contentserver.torque.RfqPeer.

If you're not sure why you're getting this error, please open an issue on GitHub.

So I disabled the Digma plugin, restarted IDEA and ran it again. Still failing. Stopped the containers - still failing.
It took me a moment to realize that Digma edited my Run Configurations (without telling me) and added some java tooling options. I deleted them and my tests are green again.

To Reproduce
Sadly, I'm not quite sure. Some tests using Mockito (4.11.0) still work with Digma enabled, others don't.

Expected behavior

  • previously green tests should not turn red when Digma is enabled
  • shouldn't change my run configs without telling me - maybe clone it or at least show me a hint

Screenshots
Can make some if required.

Plugin version
2.0.187+232

Additional context
It's an old java 8 project using ant.

@doppleware
Copy link
Contributor

doppleware commented Oct 27, 2023

Hi! We found this issue with a few other users, there is an easy solution to it luckily.
We'll add specific documentation since you're the fourth person to encounter it :)

From the thread:
"I got some feedback from OTEL.
and seems that need to disable some ability of OTEL in order for it to work.
can you please try the following
assuming you're using Gradle (kotlin) please add the following to the gradle build file (build.gradle.kts)
tasks.test {
systemProperties(Pair("otel.javaagent.experimental.field-injection.enabled", "false"))
}
if you're using Gradle groovy (build.gradle) so please add the following:
test {
systemProperty 'otel.javaagent.experimental.field-injection.enabled', 'false'
}"

Let me know if this solves your issue!

@black-snow
Copy link
Author

Thanks @doppleware

Setting -Dotel.javaagent.experimental.field-injection.enabled=false helps - maybe the default should then be not to use experimental features?

@doppleware
Copy link
Contributor

doppleware commented Nov 3, 2023

Yes we will make that recommendation to the OTEL team, in the meantime, we are considering setting this flag ourselves on any run if Digma observability is enabled.
digma-ai/digma-intellij-plugin#1267

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

No branches or pull requests

2 participants