Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing JNI Calls

I have an Android JNI wrapper for some C++ code. The C++ code has it's own set of unit tests.
I want to write Java unit-tests for the JNI wrapper class.

Is there a way to unit-test the Android JNI .so wrapper API from the desktop console e.g. on Windows? Maybe using a desktop Java framework but with all the Android SDK calls?

like image 946
Adi Shavit Avatar asked Apr 24 '14 11:04

Adi Shavit


1 Answers

Since the class that calls into native is just a wrapper class, then you can just unit test the JNI layer. If that is what you want, then it would be a bit hard to unit test your JNI functions directly. However, you can still take the "core" of your JNI function that does all the work and put that in a separate .c file. So basically, you would include your new class in the JNI class and make that class do all the wor. Now, you would have a .c class with a set of methods that can be easily unit tested.

Hope that helps!

like image 92
sasfour Avatar answered Sep 18 '22 11:09

sasfour