Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android robolectric不支持sqlite中的大容量插入_Android_Mysql_Sqlite_Junit_Robolectric - Fatal编程技术网

Android robolectric不支持sqlite中的大容量插入

Android robolectric不支持sqlite中的大容量插入,android,mysql,sqlite,junit,robolectric,Android,Mysql,Sqlite,Junit,Robolectric,我用下面的代码进行了junit测试 @RunWith(RobolectricTestRunner.class) public class AccountDAOTest { } 在我的DadatabaseHelper中,执行下面的查询 public static final String INIT_DATA = "insert into STATE(STATEID, STATENAME, STATECODE) VALUES\n" + "(1, 'Jammu

我用下面的代码进行了junit测试

@RunWith(RobolectricTestRunner.class)

 public class AccountDAOTest {

}
在我的
DadatabaseHelper
中,执行下面的查询

 public static final String INIT_DATA = "insert into STATE(STATEID, STATENAME, STATECODE) VALUES\n" +
                "(1, 'Jammu and Kashmir', 'JK'),\n" +
                "(2, 'Himachal Pradesh', 'HP')"
  sqlitedatabase.execSQL(INIT_DATA);
以上代码在模拟器/Android手机上运行。但当我运行junit作为测试时,它会失败并抛出下面的错误

android.database.sqlite.SQLiteException: Cannot prepare statement, base error code: 1

at org.robolectric.shadows.ShadowSQLiteConnection.rethrow(ShadowSQLiteConnection.java:56)
at org.robolectric.shadows.ShadowSQLiteConnection.access$500(ShadowSQLiteConnection.java:33)
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.execute(ShadowSQLiteConnection.java:466)
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.prepareStatement(ShadowSQLiteConnection.java:376)
at org.robolectric.shadows.ShadowSQLiteConnection.nativePrepareStatement(ShadowSQLiteConnection.java:67)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.__constructor__(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
at com.bizega.bondacc.database.DatabaseHelper.onCreate(DatabaseHelper.java:145)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at AccountDAOTest.setUp(AccountDAOTest.java:32)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
android.database.sqlite.SQLiteException:无法准备语句,基本错误代码:1
位于org.roblectric.shadows.ShadowSQLiteConnection.rethrow(ShadowSQLiteConnection.java:56)
位于org.roblectric.shadows.ShadowSQLiteConnection.access$500(ShadowSQLiteConnection.java:33)
位于org.roblectric.shadows.ShadowSQLiteConnection$Connections.execute(ShadowSQLiteConnection.java:466)
位于org.roblectric.shadows.ShadowSQLiteConnection$Connections.prepareStatement(ShadowSQLiteConnection.java:376)
位于org.roblectric.shadows.ShadowSQLiteConnection.nativePrepareStatement(ShadowSQLiteConnection.java:67)
在android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)中
位于android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
位于android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
位于android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
在android.database.sqlite.SQLiteProgram.\uuuuu构造函数\uuuuu(SQLiteProgram.java:58)
位于android.database.sqlite.SQLiteProgram.(SQLiteProgram.java)
位于android.database.sqlite.SQLiteStatement.(SQLiteStatement.java)
位于android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663)
位于android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
位于com.bizega.bondacc.database.DatabaseHelper.onCreate(DatabaseHelper.java:145)
位于android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
位于android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
在AccountDAOTest.setUp(AccountDAOTest.java:32)
位于org.junit.runners.model.FrameworkMethod$1.runReflectVeCall(FrameworkMethod.java:44)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
位于org.junit.runners.model.FrameworkMethod.invokeeexplosive(FrameworkMethod.java:41)
位于org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
位于org.junit.internal.runners.statements.runafter.evaluate(runafter.java:31)
在此方面的任何帮助都将不胜感激


提前感谢。

您有没有找到解决方案?