我正在尝试在 android 应用程序中的代码块上编写一个 Android 测试用例。代码块将与数据库(sqlcipher 库函数)特别是 dbopen() 函数进行交互。运行应用程序时,它工作正常。当我们尝试为该代码块(涉及数据库交互)执行测试用例时。它给出以下错误:java.lang.UnsatisfiedLinkError: dbopen
任何人都可以对此进行调查并提出建议。
测试用例不能有权调用正在调用 sqlcipher 库函数的函数。需要任何权限,或者这种类型的测试用例是否有任何特定程序?
完整的错误日志:
04-30 12:08:33.997: I/TestRunner(2169): started: teststateMachine(com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest)
04-30 12:08:34.147: W/dalvikvm(2169): No implementation found for native Linfo/guardianproject/database/sqlcipher/SQLiteDatabase;.dbopen (Ljava/lang/String;I)V
04-30 12:08:34.164: I/TestRunner(2169): failed: teststateMachine(com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest)
04-30 12:08:34.164: I/TestRunner(2169): ----- begin exception -----
04-30 12:08:34.184: I/TestRunner(2169): java.lang.UnsatisfiedLinkError: dbopen
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.dbopen(Native Method)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.<init>(SQLiteDatabase.java:1870)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:863)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:897)
04-30 12:08:34.184: I/TestRunner(2169): at info.guardianproject.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.database.SendQueueDBAdapter.open(SendQueueDBAdapter.java:45)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.database.SendQueueDBAdapter.databaseHelperInstance(SendQueueDBAdapter.java:38)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.common.ApplicationController.startDatabase(ApplicationController.java:530)
04-30 12:08:34.184: I/TestRunner(2169): at com.americanlogistics.mdd.rhapsody.view.test.SigninViewsateMachineTest.teststateMachine(SigninViewsateMachineTest.java:61)
04-30 12:08:34.184: I/TestRunner(2169): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 12:08:34.184: I/TestRunner(2169): at java.lang.reflect.Method.invoke(Method.java:507)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.runTest(TestCase.java:154)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.runBare(TestCase.java:127)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult$1.protect(TestResult.java:106)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult.runProtected(TestResult.java:124)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestResult.run(TestResult.java:109)
04-30 12:08:34.184: I/TestRunner(2169): at junit.framework.TestCase.run(TestCase.java:118)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
04-30 12:08:34.184: I/TestRunner(2169): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
04-30 12:08:34.184: I/TestRunner(2169): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
04-30 12:08:34.184: I/TestRunner(2169): ----- end exception -----
代码:
测试用例中的下面一行是间接调用 sqlcipher 库函数。
ApplicationController.getInstance().startDatabase(this.getContext().getApplicationContext());