我与Framework Robolectric
和Android
以及Gradle
合作过。我使用适当的构建变体(单元测试)方法进行了一些单元测试。
但是,我无法获得包含两个测试MyAppConfigurationActivityTest
的成功状态
个别测试用例testMyAppConfigurationActivity_NotNull
和testMyAppConfigurationActivity_GetListNotNull
。
当我运行MyAppConfigurationActivityTest
时,我得到下面描述的例外情况:
java.lang.RuntimeException: java.lang.IllegalStateException: Illegal connection pointer 216. Current pointers for thread Thread[pool-4-thread-1,5,main] []
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.execute(ShadowSQLiteConnection.java:470)
at org.robolectric.shadows.ShadowSQLiteConnection.nativeResetStatementAndClearBindings(ShadowSQLiteConnection.java:286)
at android.database.sqlite.SQLiteConnection.nativeResetStatementAndClearBindings(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.releasePreparedStatement(SQLiteConnection.java:915)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:519)
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.SQLiteQuery.<init>(SQLiteQuery.java)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at com.j256.ormlite.android.AndroidDatabaseConnection.queryForOne(AndroidDatabaseConnection.java:190)
at com.j256.ormlite.stmt.mapped.MappedQueryForId.execute(MappedQueryForId.java:38)
at com.j256.ormlite.stmt.StatementExecutor.queryForId(StatementExecutor.java:85)
at com.j256.ormlite.dao.BaseDaoImpl.queryForId(BaseDaoImpl.java:223)
at com.j256.ormlite.dao.RuntimeExceptionDao.queryForId(RuntimeExceptionDao.java:84)
at com.sample.android.ui.MyAppConfigurationActivity.onCreate(MyAppConfigurationActivity.java:105)
at android.app.Activity.performCreate(Activity.java:5933)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:122)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:304)
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:45)
at org.robolectric.util.ActivityController.create(ActivityController.java:118)
at org.robolectric.util.ActivityController.create(ActivityController.java:129)
at com.sample.android.ui.tests.activity.MyAppConfigurationActivityTest.testMyAppConfigurationActivity_NotNull
奇怪的是,只有在我上课时才会启动异常
MyAppConfigurationActivityTest
。
另一方面,当我单独运行每个测试用例testMyAppConfigurationActivity_NotNull
或
testMyAppConfigurationActivity_GetListNotNull
无异常启动。
对此有何想法?
我真的很感激有关这个问题的任何帮助。