I have a use case where it would be really cool to mock/stub/spy a
native method. Below two code snipplets.
However, I always get a java.lang.UnsatisfiedLinkError:
ExampleDto.getName()Ljava/lang/String;
I did not find evidence that Mockito is able to mock/stub/spy native
methods - is that true? (Btw. I am using Mockito 1.8.5 currently).
Thanks :)
Best,
Raphael
EXAMPLE CODE:
//The class to mock:
public class ExampleDto extends JavaScriptObject {
public ExampleDto() {};
public native final String getName() /*-{
return this.name;
}-*/;
}
//Mocking code using a spy:
ExampleDto exampletDto
= Mockito.spy(new ExampleDto());
Mockito.doReturn("").when(exampleDto).getName();
// this results in a java.lang.UnsatisfiedLinkError:
ExampleDto.getName()Ljava/lang/String;
Cheers,
Felix
> --
> You received this message because you are subscribed to the Google Groups "mockito" group.
> To post to this group, send email to moc...@googlegroups.com.
> To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
>
>
I completely agree. We got some constraints in our app that lead to
such strange "DTO"s. Using interfaces is also a good idea, however I
would like to omit that extra bit of code.
So. Basically there is no way to mock native methods using current
Mockito... Right?
Thanks,
Raphael
Thanks!
Cheers,
Raphael