[Android] Disable coroutines blocking check in unit tests
Geoffrey Métais
git at videolan.org
Thu Aug 9 17:34:18 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug 9 17:32:29 2018 +0200| [1b55168a68cbfb0fa5c40f3ab2ad704f79b0ecea] | committer: Geoffrey Métais
Disable coroutines blocking check in unit tests
> https://code.videolan.org/videolan/vlc-android/commit/1b55168a68cbfb0fa5c40f3ab2ad704f79b0ecea
---
.../videolan/vlc/repository/BrowserFavRepositoryTest.kt | 1 +
.../org/videolan/vlc/repository/SlaveRepositoryTest.kt | 16 +++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/vlc-android/test/org/videolan/vlc/repository/BrowserFavRepositoryTest.kt b/vlc-android/test/org/videolan/vlc/repository/BrowserFavRepositoryTest.kt
index 7f1fd383f..7e1c9d6c8 100644
--- a/vlc-android/test/org/videolan/vlc/repository/BrowserFavRepositoryTest.kt
+++ b/vlc-android/test/org/videolan/vlc/repository/BrowserFavRepositoryTest.kt
@@ -57,6 +57,7 @@ class BrowserFavRepositoryTest {
private lateinit var browserFavRepository: BrowserFavRepository
@Before
fun init() {
+ System.setProperty("kotlinx.coroutines.blocking.checker", "disable")
val db = mock<MediaDatabase>()
`when`(db.browserFavDao()).thenReturn(browserFavDao)
browserFavRepository = BrowserFavRepository(browserFavDao)
diff --git a/vlc-android/test/org/videolan/vlc/repository/SlaveRepositoryTest.kt b/vlc-android/test/org/videolan/vlc/repository/SlaveRepositoryTest.kt
index dfb9493c4..5489508c3 100644
--- a/vlc-android/test/org/videolan/vlc/repository/SlaveRepositoryTest.kt
+++ b/vlc-android/test/org/videolan/vlc/repository/SlaveRepositoryTest.kt
@@ -29,15 +29,16 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
-import org.mockito.Mockito.*
-import org.videolan.vlc.database.SlaveDao
-import org.videolan.vlc.database.models.Slave
-import org.videolan.vlc.util.TestUtil
import org.mockito.ArgumentMatchers.anyString
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.verify
+import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
-import org.powermock.api.mockito.PowerMockito
import org.videolan.vlc.database.MediaDatabase
+import org.videolan.vlc.database.SlaveDao
+import org.videolan.vlc.database.models.Slave
+import org.videolan.vlc.util.TestUtil
import org.videolan.vlc.util.argumentCaptor
import org.videolan.vlc.util.mock
import org.videolan.vlc.util.uninitialized
@@ -53,17 +54,18 @@ class SlaveRepositoryTest {
val instantExecutorRule = InstantTaskExecutorRule()
@Before fun init() {
+ System.setProperty("kotlinx.coroutines.blocking.checker", "disable")
val db = mock<MediaDatabase>()
`when`(db.slaveDao()).thenReturn(slaveDao)
slaveRepository = SlaveRepository(slaveDao)
}
- @Test fun saveOneSlave_getSlaveShouldReturnOne() = runBlocking<Unit> {
+ @Test fun saveOneSlave_getSlaveShouldReturnOne() = runBlocking {
val fakeSlave = TestUtil.createSubtitleSlavesForMedia("foo.mkv", 1)[0]
slaveRepository.saveSlave(fakeSlave.mediaPath, fakeSlave.type, fakeSlave.priority, fakeSlave.uri)
- var inserted = argumentCaptor<Slave>()
+ val inserted = argumentCaptor<Slave>()
verify(slaveDao).insert(inserted.capture() ?: uninitialized())
assertThat(inserted.value, `is`(fakeSlave))
More information about the Android
mailing list