Skip to content

Unit tests fail after kover is added to project #730

@josemssilva

Description

@josemssilva

Describe the bug
After adding kover to the project, unit tests started failing for unexpected reasons. The issue seems related to MockK, however it isn't clear what is causing it, and it only happens once kover is integrated.

Errors

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
	at io.mockk.proxy.jvm.transformation.JvmInlineInstrumentation.retransform(JvmInlineInstrumentation.kt:28)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$doCancel$1.invoke(RetransformInlineInstrumentation.kt:38)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$doCancel$1.invoke(RetransformInlineInstrumentation.kt:32)
	at io.mockk.proxy.common.transformation.ClassTransformationSpecMap.applyTransformation(ClassTransformationSpecMap.kt:41)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation.doCancel(RetransformInlineInstrumentation.kt:32)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation.access$doCancel(RetransformInlineInstrumentation.kt:6)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1$1.invoke(RetransformInlineInstrumentation.kt:17)
	at io.mockk.proxy.common.transformation.RetransformInlineInstrumentation$execute$1$1.invoke(RetransformInlineInstrumentation.kt:17)
	at io.mockk.proxy.common.CancelableResult.cancel(CancelableResult.kt:22)
	at io.mockk.proxy.common.CancelableResult$alsoOnCancel$1.invoke(CancelableResult.kt:30)
	at io.mockk.proxy.common.CancelableResult$alsoOnCancel$1.invoke(CancelableResult.kt:29)
	at io.mockk.proxy.common.CancelableResult.cancel(CancelableResult.kt:22)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler.doCancel(JvmConstructorMockFactory.kt:242)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler.access$doCancel(JvmConstructorMockFactory.kt:155)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler$push$2.invoke(JvmConstructorMockFactory.kt:217)
	at io.mockk.impl.instantiation.JvmConstructorMockFactory$ConstructorInvocationHandler$push$2.invoke(JvmConstructorMockFactory.kt:216)
	at io.mockk.MockKCancellationRegistry$RegistryPerType.cancelAll(API.kt:2440)
	at io.mockk.MockKCancellationRegistry.cancelAll(API.kt:2469)

Expected behavior
Tests shouldn't fail, as it was happening prior to introducing kover.

Reproducer
Only happens in test classes, when unmockkAll() is called.

Reports

Environment

  • Kover Gradle Plugin version: 0.9.1
  • Gradle version: 8.6
  • Kotlin project type: Kotlin/Android
  • Coverage Toolset (if customized in build script): -
  • Other context important for this bug: -

Metadata

Metadata

Assignees

Labels

BugBug issue typeS: waiting for clarificationStatus: additional information required to proceed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions