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

probe-android: Many unit tests failing on the debug build type #2777

Open
sdsantos opened this issue Jul 15, 2024 · 0 comments · Fixed by ooni/probe-android#785
Open

probe-android: Many unit tests failing on the debug build type #2777

sdsantos opened this issue Jul 15, 2024 · 0 comments · Fixed by ooni/probe-android#785
Labels
bug Something isn't working triage

Comments

@sdsantos
Copy link

Describe the bug

Around 79 unit tests are failing when run with the debug build type, the usual build type used when developing the app.

To Reproduce

Run gradlew testOoniStableFullDebug or open and run a test manually on the Android Studio UI, with a buildVariant selected that ends in Debug.

Expected behavior

Those tests should have the same result and the release build type, since there's no applicable difference between the 2 build types.

Stacktrace

Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
	at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:85)
	at jdk.proxy4/jdk.proxy4.$Proxy41.isTypeMockable(Unknown Source)
	at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:78)
	at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
	at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:275)
	at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:236)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:82)
	at org.mockito.Mockito.mock(Mockito.java:2104)
	at org.mockito.Mockito.mock(Mockito.java:2019)
	at org.openobservatory.ooniprobe.domain.GetTestSuiteTest.testGetFromResult(GetTestSuiteTest.java:69)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:489)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:291)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:104)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Internal problem occurred, please report it. Mockito is unable to load the default implementation of class that is a part of Mockito distribution. Failed to load interface org.mockito.plugins.MockMaker
	at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:105)
	at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.getDefaultPlugin(DefaultMockitoPlugins.java:79)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:75)
	at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:49)
	at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:29)
	at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:26)
	at org.mockito.internal.MockitoCore.<clinit>(MockitoCore.java:71)
	at org.mockito.Mockito.<clinit>(Mockito.java:1683)
	... 19 more
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.mockito.internal.configuration.plugins.DefaultMockitoPlugins.create(DefaultMockitoPlugins.java:103)
	... 26 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException: 
Could not initialize inline Byte Buddy mock maker.

It appears as if your JDK does not supply a working agent attachment mechanism.
Java               : 17
JVM vendor name    : JetBrains s.r.o.
JVM vendor version : 17.0.10+0-17.0.10b1087.21-11609105
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 17.0.10+0-17.0.10b1087.21-11609105
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 14.5

	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.<init>(InlineDelegateByteBuddyMockMaker.java:260)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:23)
	... 32 more
Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process - set a property net.bytebuddy.agent.attacher.dump to dump the process output to a file at the specified location
	at net.bytebuddy.agent.ByteBuddyAgent.installExternal(ByteBuddyAgent.java:706)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:636)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:616)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:568)
	at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:545)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.<clinit>(InlineDelegateByteBuddyMockMaker.java:133)
	... 33 more
@sdsantos sdsantos added bug Something isn't working triage labels Jul 15, 2024
aanorbel pushed a commit to ooni/probe-android that referenced this issue Jul 17, 2024
I haven't created a ticket for these changes.

## Proposed Changes

- Fix `ResultTest.getLastResult` by ensuring that the first result
really has a start_time before the second result
  - Fix `BuildConfig` warning by changing to the new configuration
- Remove the `mockito-inline` dependency, since it's no longer needed
for Mockito 5

### Context

- This PR started as an attempt to fix
ooni/probe#2777 but I wasn't able to do it yet
@sdsantos sdsantos reopened this Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant