Mocking and open


The default behaviour in Kotlin is that all class members are close to extensibility, e.g. you have to explicitly define them as open.

I’m using an injection framework and as a result I encapsulate a lot of my functionality in separate service classes which I can mock easily. In order to mock I need to open the class and its method.

I’m thinking out loud, it kinda defies the idea of the default behaviour, I mean unlike Java I need to actually go over all of my service classes and add open. What would have been great is to open all methods when running them in a test context.

Any thoughts ?


Thake a look at this plugin



So cool! works


As well if have some time try this one