I'm trying to mock some interfaces using Mockk.
At some point, I have to create a mock that implements 2 interfaces.
For instance, using Moq in C#, I can do that :
// implementing multiple interfaces in mock
var foo = new Mock<IFoo>();
var disposableFoo = foo.As<IDisposable>();
// now IFoo mock also implements IDisposable :)
disposableFoo.Setup(df => df.Dispose());
Is there a way to do that with Mockk ?
If I try something like
val foo : IFoo = mockk()
every { (foo as AutoCloseable).close() } just Runs
I get the following error (which makes sense) :
com.example.IFoo$Subclass0 cannot be cast to java.lang.AutoCloseable
I saw in the documentation that I can specify additional interfaces with spyk
, but I don't want to use an actual implementation here.
Is there a way to do that ? Is there another approach ?