33 lines
867 B
Kotlin
33 lines
867 B
Kotlin
package gq.kirmanak.mealient.test
|
|
|
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
|
import gq.kirmanak.mealient.logging.Logger
|
|
import io.mockk.MockKAnnotations
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
|
import kotlinx.coroutines.test.resetMain
|
|
import kotlinx.coroutines.test.setMain
|
|
import org.junit.After
|
|
import org.junit.Before
|
|
import org.junit.Rule
|
|
|
|
@OptIn(ExperimentalCoroutinesApi::class)
|
|
open class BaseUnitTest {
|
|
|
|
@get:Rule
|
|
val instantExecutorRule = InstantTaskExecutorRule()
|
|
|
|
protected val logger: Logger = FakeLogger()
|
|
|
|
@Before
|
|
open fun setUp() {
|
|
MockKAnnotations.init(this)
|
|
Dispatchers.setMain(UnconfinedTestDispatcher())
|
|
}
|
|
|
|
@After
|
|
fun tearDown() {
|
|
Dispatchers.resetMain()
|
|
}
|
|
} |