Re: Unit Tests with NDK

3,235 views
Skip to first unread message

RichardC

unread,
Mar 13, 2013, 2:05:34 PM3/13/13
to andro...@googlegroups.com
Use the Android Java test framework:

Make JNI calls from it to test your C/C++.

On Wednesday, March 13, 2013 1:00:13 PM UTC, Developer at Works wrote:
Hi Everyone..

I want to write few unit test cases for my C++ code, written for my android-app via ndk and I'm not getting any pointers how can I get this thing done.
So far, my findings are..One can use Google Test(gtest) for this, but I've no idea how to use the same and integrate with Android-build process in Eclipse(ADT).

Hence I need your help; I'm open for suggestions, even changing test-framework isn't a problem for me.
--
Thank you
Abhinav

Li Chen

unread,
Mar 13, 2013, 10:40:30 PM3/13/13
to andro...@googlegroups.com
Perhaps you can have a try with CppUTest. It's quite simple.
---
http://www.cpputest.org/

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

alan

unread,
Mar 14, 2013, 7:50:34 AM3/14/13
to andro...@googlegroups.com
Just write a junit class which calls via JNI through to the main method of the testing framework of your choice, then assert that the result is 0.

Michael Moussa

unread,
Mar 14, 2013, 9:50:24 AM3/14/13
to andro...@googlegroups.com
I agree with alan and Richard. Just expose your native code through jni to java and run android junit tests against it like you would any normal android junit test.

Ken Turkowski

unread,
Mar 18, 2013, 4:11:30 PM3/18/13
to andro...@googlegroups.com
Since my code doesn't use Java, I haven't tried to use Eclipse. I just use a make file. Here are the necessities:

- use a standalone toolchain:
$(NDK_DIR)/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/tmp/my-android-toolchain
- Compile flags
CPPFLAGS += -DANDROID -DGTEST_HAS_CLONE=0
CFLAGS += -DANDROID
CXXFLAGS +=  -fno-rtti  -fno-exceptions
- build stl:
cd $(NDK_DIR)sources/cxx-stl/stlport && $(NDK_DIR)build/tools/build-stlport.sh


On Mar 13, 2013, at 6:00 AM, Developer at Works <develope...@gmail.com> wrote:

Hi Everyone..

I want to write few unit test cases for my C++ code, written for my android-app via ndk and I'm not getting any pointers how can I get this thing done.
So far, my findings are..One can use Google Test(gtest) for this, but I've no idea how to use the same and integrate with Android-build process in Eclipse(ADT).

Hence I need your help; I'm open for suggestions, even changing test-framework isn't a problem for me.
--
Thank you
Abhinav


ravi shah

unread,
Aug 26, 2013, 1:38:31 AM8/26/13
to andro...@googlegroups.com, develope...@gmail.com
hey can you give me the proper steps how to run CPPUTEST in android NDK......
Reply all
Reply to author
Forward
0 new messages