When one should use interfaces over mocking framew...
# test
u
When one should use interfaces over mocking framework?
m
I wouldn't say it is one over the other... having interfaces allow you to mock behavior
otherwise, in kotlin, you would have to open every class
f
m
true, I was saying in general
u
yea I know, but is there some heuristic, or maybe in libraries?
f
Generally at the application layer I skip the interface if there's only one implementation
c
for me mocking kotlin classes never works, so i always extract an inteface when i need a mock. and i also found that its good to have mock implementations for the important classes in my app (instead of using dynamic mocks)
u
Why would it not work?
c
i sometimes had the problem that the methods did not return the values from the mock setup so now I'm always extracting an interface when i need to mock something
u
thats odd, are you refering to java mockito? Ive had issue with it but mockito-kotlin works flawless afaik