quarkus-mockk icon indicating copy to clipboard operation
quarkus-mockk copied to clipboard

Support `any()` in mocking methods

Open c15yi opened this issue 7 months ago • 0 comments

Description

When injecting a mock into a QuarkusTest I am not able to use the any() matcher in the every method to specify a mock implementation for my function, if the function has a non-primary parameter.

Reproducing Project

https://github.com/ChristianNavolskyi/quarkus-reproducer-mock

Checkout and run ./gradlew quarkusTest

Error Message

Failed matching mocking signature for

left matchers: [any()]
io.mockk.MockKException: Failed matching mocking signature for

left matchers: [any()]
	at io.mockk.impl.recording.SignatureMatcherDetector.detect(SignatureMatcherDetector.kt:97)
	at io.mockk.impl.recording.states.RecordingState.signMatchers(RecordingState.kt:39)
	at io.mockk.impl.recording.states.RecordingState.round(RecordingState.kt:31)
	at io.mockk.impl.recording.CommonCallRecorder.round(CommonCallRecorder.kt:50)
	at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:62)
	at io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:30)
	at io.mockk.MockKDsl.internalEvery(API.kt:94)
	at io.mockk.MockKKt.every(MockK.kt:143)
	at com.arconsis.ExampleResourceTest.testHelloEndpoint(ExampleResourceTest.kt:20)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:1017)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:831)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

c15yi avatar Jul 02 '24 15:07 c15yi