I know it sounds weird, but does exist a way to co...
# mockk
m
I know it sounds weird, but does exist a way to copy an initialized mock? I couldn't find a way...
m
what do you want to do exactly? copying a mock does not seem like a very good idea to me 😅
m
yeah I know 😛 it's always the same problem, working on legacy code, where a lot of mocks (worse, mocked data) are declared with lots of stubbing; so I was looking for a short way to copy one and add some different stubbing. But if it's not doable, it's not a problem. In the end I encapsulated the existing mock creation in a function and carried on.
I was looking if anything like this existed:
Copy code
val newMock = mockk(anotherMock) {
  every {...}
  ...
}
m
it doesn’t, but if you want to put together a PR about it i won’t complain 🙂
m
haha nice weekend project idea! 😄
I'll keep that in mind
m
the weather forecast for the weekend in Italy is awful anyway 😄
m
haha yes! terrible rainy week...
https://github.com/mockk/mockk/issues/1213 I finally put myself together and meanwhile created an issue