Open full view…

Mocking final classes

Fri, 11 Aug 2017 11:40:38 GMT

Mockito 2 contains capability to mock final classes. It is more less essential when the codebase contains kotlin classes as they are closed by default.. Could you add support for generating mocked dependencies even for final classes? Maybe at least some configuration option to enable it...

Mon, 04 Sep 2017 15:44:16 GMT

koperko sorry for the late reply, Adding an optional support for mocking final class types with Mockito is a great idea. I didn't even knew they had this option. I took a note that this is something that should be added to a future configuration screen. Since it might take time until a configuration screen is introduced, how about the following alternative as a quick fix?: When generating a test, TestMe plugin would generate Mockito mocks for final class types if such [Mockito option is turned on]( in the target module where the test is generated. Meaning that the classpath of the target module or one of its library/module dependencies has the resource file `mockito-extensions/org.mockito.plugins.MockMaker` and that file specifies the option `mock-maker-inline`. Would this address your needs?

Wed, 27 Sep 2017 19:21:57 GMT

Mocking of final classes, as described above, has been added to latest release - version 1.6