В следующем проекте
https://github.com/Crash1hd/MultipleTestTesting
Я получаю следующую ошибку
java.lang.IllegalStateException: Illegal connection pointer 1. Current pointers for thread Thread[DefaultDispatcher-worker-1 @coroutine#3,5,SDK 28] []
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.getConnection(ShadowSQLiteConnection.java:367)
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.prepareStatement(ShadowSQLiteConnection.java:416)
at org.robolectric.shadows.ShadowSQLiteConnection.nativePrepareStatement(ShadowSQLiteConnection.java:89)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:562)
at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:549)
at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:460)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.beginTransaction(FrameworkSQLiteDatabase.java:69)
at androidx.room.RoomDatabase.beginTransaction(RoomDatabase.java:277)
at com.mycomp.roomwordsample.data.db.WordDao_Impl.deleteAll(WordDao_Impl.java:81)
at com.mycomp.roomwordsample.data.db.WordRepository$deleteAllLogsOlderThan$2.invokeSuspend(WordRepository.kt:28)
at |b|b|b(Coroutine boundary.|b(|b)
at com.mycomp.roomwordsample.ui.WordViewModel$deleteAllLogsOlderThanA$1.invokeSuspend(WordViewModel.kt:36)
Caused by: java.lang.IllegalStateException: Illegal connection pointer 1. Current pointers for thread Thread[DefaultDispatcher-worker-1 @coroutine#3,5,SDK 28] []
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.getConnection(ShadowSQLiteConnection.java:367)
at org.robolectric.shadows.ShadowSQLiteConnection$Connections.prepareStatement(ShadowSQLiteConnection.java:416)
at org.robolectric.shadows.ShadowSQLiteConnection.nativePrepareStatement(ShadowSQLiteConnection.java:89)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:903)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:562)
at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323)
at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298)
at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:549)
at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:460)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.beginTransaction(FrameworkSQLiteDatabase.java:69)
at androidx.room.RoomDatabase.beginTransaction(RoomDatabase.java:277)
at com.mycomp.roomwordsample.data.db.WordDao_Impl.deleteAll(WordDao_Impl.java:81)
at com.mycomp.roomwordsample.data.db.WordRepository$deleteAllLogsOlderThan$2.invokeSuspend(WordRepository.kt:28)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
Когда я запускаю этот набор тестов https://github.com/Crash1hd/MultipleTestTesting/blob/master/app/src/test/java/com/mycomp/roomwordsample/WordDaoTestA.kt
Похоже, что это связано с функцией, которую я вызываю в initializationLogging в WordApplication https://github.com/Crash1hd/MultipleTestTesting/blob/master/app/src/main/java/com/mycomp/roomwordsample/WordApplication.kt
Закомментируем LogA.purgeOldLogsGreaterThan (7) в этой строке все тесты проходят.
Я в недоумении, почему это не удается?каждый тест точно такой же, и все они работают (но не все сразу).
Мне интересно, связано ли это с тем, как я вызываю WordViewModel в приложении ...