我正在研究一个相当复杂的C++库,我计划使用googletest for Android NDK正确测试.
到目前为止,我按照谷歌测试示例,并像这样构建项目:
Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := foo LOCAL_SRC_FILES := foo.cpp include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := foo_unittest LOCAL_SRC_FILES := foo_unittest.cpp LOCAL_SHARED_LIBRARIES := foo LOCAL_STATIC_LIBRARIES := googletest_main include $(BUILD_EXECUTABLE) $(call import-module,third_party/googletest)
我使用脚本文件构建并调用测试:
adb push libs/armeabi/libfoo.so //data/local/tmp/ adb push libs/armeabi/libgnustl_shared.so //data/local/tmp/ adb push libs/armeabi/foo_unittest //data/local/tmp/ adb shell chmod 775 //data/local/tmp/foo_unittest adb shell "LD_LIBRARY_PATH=//data/local/tmp //data/local/tmp/foo_unittest"
这适用于任何没有很多引用的纯C++代码,但我的很多代码实际上依赖于java/jni调用.如何使用完整的apk文件运行googletest,该文件不仅包含C++代码,还包含java和资源?