I am writing JUnit test cases. I have a class that contains APIs which call JNI APIs.
public class Test {
public native int getId_native();
public void doSomething() {
// do init
int id = getId_native();
// Get name by Id
}
}
And I am writing unit test for doSomething()
API. The problem that I am facing is, as soon as the JNI API(getId_native())
is called, UnsatisfiedLinkError is thrown and caught in my JUnit test and the test ends. Control does not proceed further to test the lines of code after the native function. This reduced the code coverage in all similar methods in the project.
Since the native methods are declared in the same class, I am unable to mock the class too.
Can someone help me how to overcome this issue?
Thanks.