Replies: 3 comments
-
Instead of disabling the check for unnecessary stubbings I moved the execution of class @BeforeEach
fun setUp() {
mockkStatic(::extractUserDetails)
//...
} But even if I remove the that static mock the behavior stays the same. Any advice on this would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
-
The same thing is happening to me |
Beta Was this translation helpful? Give feedback.
-
I am facing the same behaviour. |
Beta Was this translation helpful? Give feedback.
-
I have a problem with what appears to be a false positive for unnecessary stubbing. This is MockK version
1.13.2
.All my Junit 5 tests are annotated as
Two of my test classes seem to interact in a "static" way in that test class
A
creates a mock instance ofX
(MessageContext
) and stubs a certain method (getResponse()
). This is the actual (abridged) code:And test class
B
, which does neither create a mock of type X, nor the real thing, and neither does the code under test, fails with Unnecessary stubbings detected for the method stubbed inA
.As soon as I annotate
A
with@Disabled
the tests in classB
run through without a problem and pass the check for unnecessary stubbing.How can I properly resolve this, i.e. not having to disable the check for unnecessary stubs?
Beta Was this translation helpful? Give feedback.
All reactions