title |
---|
MockK deprecation |
It is important to make right decisions about deprecation of some functionality. Otherwise lib code or user code may become a mess. I know it may be inconvenient for end user, but here sooner is better than later.
From the beginning syntax of scoped mocking was weird. But not only that. More and more I am finding that people misusing it in code I see through GH, Gitter and Slack. This misuse exposes tests to errors and dependency.
Old syntax | New syntax | Annotation |
---|---|---|
objectMockk(Obj).use { // mocking, usage, verification } |
mockkObject(Obj) // mocking, usage, verification |
|
staticMockk<Cls>().use { // mocking, usage, verification } |
mockkStatic(Cls::class) // mocking, usage, verification |
|
So basically there is no scopes, mock
, unmock
or use
.
There is just one call that creates a mock or clears if it is already created.
It should be safe to have only that one declaration in test before using mock.