Gasan
09/19/2022, 11:52 AMJvmStatic
I want to write a junit/mockito test where I want to mock the method. Is there a way to do it? What if I remove JvmStatic
? What are my options?
I think it’s a part of the broader topic - how does the companion object relate to beans/singleton concepts of Spring
, for example.
Ideally, I would want no static methods at all. But instead having a singleton-y classes that I could mock or do whatever I can with the normal classes.ephemient
09/19/2022, 11:55 AMGasan
09/19/2022, 11:56 AMGasan
09/19/2022, 11:56 AMephemient
09/19/2022, 11:57 AMmockkObject
on the companion object, and it does not relateephemient
09/19/2022, 11:57 AMmockkStatic
themephemient
09/19/2022, 11:58 AMephemient
09/19/2022, 11:59 AMGasan
09/19/2022, 12:00 PMephemient
09/19/2022, 12:02 PMGasan
09/19/2022, 12:03 PMJvmStatic
, then there should be a way around. As it won’t be a static (from java point of view), so there should be a way to mock it. But then I would have to have it as a dependency.Gasan
09/19/2022, 12:05 PMGasan
09/19/2022, 12:06 PMGasan
09/19/2022, 12:07 PMGasan
09/19/2022, 12:07 PMGasan
09/19/2022, 12:08 PM