diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 8d7816c..a2a0c48 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -123,11 +123,7 @@ object Libraries { object Coroutines { private const val COROUTINES_ANDROID_VERSION = "1.6.0" - - object Test { - const val TEST = - "org.jetbrains.kotlinx:kotlinx-coroutines-test:$COROUTINES_ANDROID_VERSION" - } + const val TEST = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$COROUTINES_ANDROID_VERSION" } } @@ -188,10 +184,6 @@ object Libraries { // Internal Libraries val DependencyHandler.TESTING - //get() = androidTestImplementation(project(Modules.TESTING)) - get() = implementation(project(Modules.TESTING)) - -val DependencyHandler.TESTING_IMPL get() = implementation(project(Modules.TESTING)) fun DependencyHandler.testing() { @@ -362,15 +354,15 @@ private fun DependencyHandler.test() { } fun DependencyHandler.androidInstrumentationTest() { - testImplementation(Libraries.Test.AndroidX.ARCH) - testImplementation(Libraries.Test.AndroidX.CORE) - testImplementation(Libraries.Test.AndroidX.JUNIT_KTX) - testImplementation(Libraries.Test.AndroidX.JUNIT_RUNNER) - testImplementation(Libraries.Test.AndroidX.JUNIT_RULES) + androidTestImplementation(Libraries.Test.AndroidX.ARCH) + androidTestImplementation(Libraries.Test.AndroidX.CORE) + androidTestImplementation(Libraries.Test.AndroidX.JUNIT_KTX) + androidTestImplementation(Libraries.Test.AndroidX.JUNIT_RUNNER) + androidTestImplementation(Libraries.Test.AndroidX.JUNIT_RULES) } private fun DependencyHandler.coroutinesTest() { - androidTestImplementation(Libraries.Kotlin.Coroutines.Test.TEST) + androidTestImplementation(Libraries.Kotlin.Coroutines.TEST) } fun DependencyHandler.hiltTest() { diff --git a/features/favorites/build.gradle.kts b/features/favorites/build.gradle.kts index 7f80a2b..1d84a97 100644 --- a/features/favorites/build.gradle.kts +++ b/features/favorites/build.gradle.kts @@ -43,8 +43,8 @@ dependencies { LOCAL_TEST TESTING - testImplementation(project(Modules.TESTING)) - testImplementation(Libraries.Kotlin.Coroutines.Test.TEST) + //MODULE_TESTING + //testImplementation(Libraries.Kotlin.Coroutines.TEST) } kapt { diff --git a/features/history/build.gradle.kts b/features/history/build.gradle.kts index 7f80a2b..39cc8a2 100644 --- a/features/history/build.gradle.kts +++ b/features/history/build.gradle.kts @@ -42,9 +42,6 @@ dependencies { DAGGER_HILT_ANDROID_TEST LOCAL_TEST TESTING - - testImplementation(project(Modules.TESTING)) - testImplementation(Libraries.Kotlin.Coroutines.Test.TEST) } kapt { diff --git a/features/language-selection/build.gradle.kts b/features/language-selection/build.gradle.kts index 7f80a2b..39cc8a2 100644 --- a/features/language-selection/build.gradle.kts +++ b/features/language-selection/build.gradle.kts @@ -42,9 +42,6 @@ dependencies { DAGGER_HILT_ANDROID_TEST LOCAL_TEST TESTING - - testImplementation(project(Modules.TESTING)) - testImplementation(Libraries.Kotlin.Coroutines.Test.TEST) } kapt { diff --git a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/viewmodel/LanguageSelectionViewModel.kt b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/viewmodel/LanguageSelectionViewModel.kt index 9b403eb..e04b35f 100644 --- a/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/viewmodel/LanguageSelectionViewModel.kt +++ b/features/language-selection/src/main/java/com/theteampotato/gifit/language_selection/viewmodel/LanguageSelectionViewModel.kt @@ -2,13 +2,17 @@ package com.theteampotato.gifit.language_selection.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope + import com.theteampotato.gifit.domain.usecase.DownloadTranslationModel import com.theteampotato.gifit.domain.usecase.SetSelectedLanguage + import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.launch + import java.lang.Exception import javax.inject.Inject +import kotlinx.coroutines.launch + @HiltViewModel class LanguageSelectionViewModel @Inject constructor( private val downloadTranslationModel: DownloadTranslationModel, diff --git a/features/search/build.gradle.kts b/features/search/build.gradle.kts index f7ac4ad..8372fea 100644 --- a/features/search/build.gradle.kts +++ b/features/search/build.gradle.kts @@ -43,10 +43,6 @@ dependencies { DAGGER_HILT_ANDROID_TEST LOCAL_TEST TESTING - - testImplementation(project(Modules.TESTING)) - testImplementation(Libraries.Kotlin.Coroutines.Test.TEST) - TURBINE } kapt { diff --git a/features/search/src/androidTest/java/com/theteampotato/gifit/home/view/SearchScreenTest.kt b/features/search/src/androidTest/java/com/theteampotato/gifit/home/view/SearchScreenTest.kt index 9c56b33..a6cf762 100644 --- a/features/search/src/androidTest/java/com/theteampotato/gifit/home/view/SearchScreenTest.kt +++ b/features/search/src/androidTest/java/com/theteampotato/gifit/home/view/SearchScreenTest.kt @@ -1,7 +1,5 @@ package com.theteampotato.gifit.home.view -import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import androidx.compose.runtime.getValue import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText @@ -9,14 +7,11 @@ import com.theteampotato.gifit.domain.usecase.* import com.theteampotato.gifit.home.viewmodel.SearchViewModel import com.theteampotato.gifit.testing.DispatcherProvider -import com.theteampotato.gifit.testing.getOrAwaitValue import com.theteampotato.gifit.ui.GIFitTheme import dagger.hilt.android.testing.HiltAndroidRule import dagger.hilt.android.testing.HiltAndroidTest import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.test.StandardTestDispatcher -import kotlinx.coroutines.test.setMain import org.junit.Before import org.junit.Rule @@ -35,6 +30,8 @@ class SearchScreenTest { @Inject lateinit var isSearchResultExist: IsSearchResultExist @Inject lateinit var removeSearchResultFromFavorites: RemoveSearchResultFromFavorites @Inject lateinit var getSearchResult: GetSearchResult + @Inject lateinit var translateText: TranslateText + @Inject lateinit var readText: ReadText private lateinit var searchViewModel: SearchViewModel @@ -52,7 +49,9 @@ class SearchScreenTest { addSearchResultToFavorites = addSearchResultToFavorites, getSearchResult = getSearchResult, isSearchResultExist = isSearchResultExist, - removeSearchResultFromFavorites = removeSearchResultFromFavorites + removeSearchResultFromFavorites = removeSearchResultFromFavorites, + translateText = translateText, + readText = readText ) composeTestRule.setContent { @@ -73,10 +72,7 @@ class SearchScreenTest { val givenValue = "Ofis" val expectedValue = "Office" - //composeTestRule.o - searchViewModel.searchKeyword(givenValue) - //searchViewModel.mSearchResultLiveData.getOrAwaitValue() composeTestRule.onNodeWithText(expectedValue).assertIsDisplayed() } diff --git a/features/search/src/androidTest/java/com/theteampotato/gifit/home/viewmodel/SearchViewModelTest.kt b/features/search/src/androidTest/java/com/theteampotato/gifit/home/viewmodel/SearchViewModelTest.kt deleted file mode 100644 index e2249f7..0000000 --- a/features/search/src/androidTest/java/com/theteampotato/gifit/home/viewmodel/SearchViewModelTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -package com.theteampotato.gifit.home.viewmodel - -import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import app.cash.turbine.test - -import com.google.common.truth.Truth.assertThat -import com.theteampotato.gifit.domain.usecase.* - -import com.theteampotato.gifit.testing.DispatcherProvider - -import dagger.hilt.android.testing.HiltAndroidRule -import dagger.hilt.android.testing.HiltAndroidTest -import kotlinx.coroutines.* -import kotlinx.coroutines.test.StandardTestDispatcher - -import javax.inject.Inject - -import kotlinx.coroutines.test.runTest -import kotlinx.coroutines.test.setMain - -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import timber.log.Timber - -import kotlin.time.Duration.Companion.seconds -import kotlin.time.ExperimentalTime - -@HiltAndroidTest -class SearchViewModelTest { - - @get:Rule - var hiltRule = HiltAndroidRule(this) - - @get:Rule - var instantTaskExecutorRule = InstantTaskExecutorRule() - - @Inject lateinit var addSearchResultEntry: AddSearchResultEntry - @Inject lateinit var addSearchResultToFavorites: AddSearchResultToFavorites - @Inject lateinit var isSearchResultExist: IsSearchResultExist - @Inject lateinit var removeSearchResultFromFavorites: RemoveSearchResultFromFavorites - @Inject lateinit var getSearchResult: GetSearchResult - - private lateinit var searchViewModel: SearchViewModel - - @Before - @OptIn(ExperimentalCoroutinesApi::class) - fun setup() { - hiltRule.inject() - - Dispatchers.setMain(StandardTestDispatcher()) - - searchViewModel = SearchViewModel( - dispatcherProvider = DispatcherProvider( - io = Dispatchers.Main, - ui = Dispatchers.Main, - default = Dispatchers.Main - ), - addSearchResultEntry = addSearchResultEntry, - addSearchResultToFavorites = addSearchResultToFavorites, - getSearchResult = getSearchResult, - isSearchResultExist = isSearchResultExist, - removeSearchResultFromFavorites = removeSearchResultFromFavorites - ) - } - - @Test - @OptIn(ExperimentalTime::class, ExperimentalCoroutinesApi::class) - fun keyword_should_return_expectedResult() = runTest { - val expectedResult = "School" - - searchViewModel.searchKeyword("Okul")?.test(timeout = 15.seconds) { - val searchResult = awaitItem() - val actualResult = searchResult?.translatedText - assertThat(actualResult).matches(expectedResult) - } - } - - @Test - @OptIn(ExperimentalTime::class, ExperimentalCoroutinesApi::class) - fun wrong_expected_result_does_not_match_with_actualResult() = runTest { - val expectedResult = "Student" - - searchViewModel.searchKeyword("Araba")?.test(timeout = 15.seconds) { - val searchResult = awaitItem() - val actualResult = searchResult?.translatedText - assertThat(actualResult).doesNotMatch(expectedResult) - } - } - - @Test - fun homeViewModel_is_not_null() { - assertThat(searchViewModel).isNotNull() - } - -} \ No newline at end of file diff --git a/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/viewmodel/SplashViewModel.kt b/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/viewmodel/SplashViewModel.kt index 815d914..0c4c1f5 100644 --- a/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/viewmodel/SplashViewModel.kt +++ b/features/splash/src/main/kotlin/com/theteampotato/gifit/splash/viewmodel/SplashViewModel.kt @@ -2,11 +2,15 @@ package com.theteampotato.gifit.splash.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope + import com.theteampotato.gifit.domain.usecase.GetSelectedLanguage + import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.withContext + import javax.inject.Inject +import kotlinx.coroutines.withContext + @HiltViewModel class SplashViewModel @Inject constructor( private val getSelectedLanguage: GetSelectedLanguage diff --git a/layers/data/src/androidTest/java/com/theteampotato/gifit/data/local/dao/SearchResultEntityDaoTest.kt b/layers/data/src/androidTest/java/com/theteampotato/gifit/data/local/dao/SearchResultEntityDaoTest.kt index 7bb2814..2e3b567 100644 --- a/layers/data/src/androidTest/java/com/theteampotato/gifit/data/local/dao/SearchResultEntityDaoTest.kt +++ b/layers/data/src/androidTest/java/com/theteampotato/gifit/data/local/dao/SearchResultEntityDaoTest.kt @@ -25,31 +25,31 @@ class SearchResultEntityDaoTest : GIFitRoomDatabaseTest() { var instantTaskExecutorRule = InstantTaskExecutorRule() private lateinit var searchResultDao: SearchResultDao - private lateinit var SearchResultEntity: SearchResultEntity + private lateinit var searchResultEntity: SearchResultEntity private lateinit var listOfResultEntities: List @Before fun init() = runBlocking { searchResultDao = database.searchResultDao() - SearchResultEntity = TestUtil.newSearch() + searchResultEntity = TestUtil.newSearch() listOfResultEntities = TestUtil.newListOfSearch() } @Test fun verify_inserted_testData_then_searchString_entity_should_be_equalTo_searchResult_searchString(): Unit = runBlocking { - searchResultDao.insert(SearchResultEntity) + searchResultDao.insert(searchResultEntity) val results = searchResultDao.getAll().getOrAwaitValue() - assertThat(results[0].searchText).isEqualTo(SearchResultEntity.searchText) + assertThat(results[0].searchText).isEqualTo(searchResultEntity.searchText) } @Test fun verify_deleted_testData_then_check_searchString_should_be_contain(): Unit = runBlocking { searchResultDao.insertAll(listOfResultEntities) - searchResultDao.insert(SearchResultEntity) + searchResultDao.insert(searchResultEntity) val result = searchResultDao.getResultById(2).getOrAwaitValue() searchResultDao.delete(result) val results = searchResultDao.getAll().getOrAwaitValue() - assertThat(results[2].searchText).contains(SearchResultEntity.searchText) + assertThat(results[2].searchText).contains(searchResultEntity.searchText) } @Test diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/BaseLocalRepository.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/ILocalOperations.kt similarity index 76% rename from layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/BaseLocalRepository.kt rename to layers/data/src/main/java/com/theteampotato/gifit/data/local/ILocalOperations.kt index 7a8a231..7a05d94 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/BaseLocalRepository.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/ILocalOperations.kt @@ -1,8 +1,8 @@ -package com.theteampotato.gifit.data.local.repository +package com.theteampotato.gifit.data.local import androidx.lifecycle.LiveData -interface BaseLocalRepository { +interface ILocalOperations { suspend fun insert(entity : T) : Long diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt index 3521bed..0d5965d 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/dao/SearchResultDao.kt @@ -18,7 +18,7 @@ interface SearchResultDao : BaseDao { fun getResultById(id: Int): LiveData @Query("SELECT * FROM SearchResult WHERE id = :id and isFavorite = 1") - fun getFavoritesResultById(id: Int): LiveData + fun getFavoritesResultById(id: Int): Flow @Query("SELECT * FROM SearchResult WHERE isFavorite = 1") fun getAllFavoritesResults(): Flow> diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/ILocalDataSource.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/ILocalDataSource.kt deleted file mode 100644 index fa2c284..0000000 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/ILocalDataSource.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.theteampotato.gifit.data.local.datasource - -import androidx.lifecycle.LiveData - -interface ILocalDataSource { - - suspend fun insert(entity: T) : Long - - suspend fun insertAll(entities: List) - - suspend fun update(entity: T) - - suspend fun delete(entity: T) - - suspend fun get(id : Int) : LiveData - - suspend fun getAll(): LiveData> - -} \ No newline at end of file diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt index 00b3d3b..8d74f30 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/datasource/LocalDataSource.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.data.local.datasource import androidx.lifecycle.LiveData +import com.theteampotato.gifit.data.local.ILocalOperations import com.theteampotato.gifit.data.local.dao.SearchResultDao import com.theteampotato.gifit.data.local.entity.SearchResultEntity @@ -11,7 +12,7 @@ import kotlinx.coroutines.flow.Flow class LocalDataSource @Inject constructor( private val searchResultDao: SearchResultDao -) : ILocalDataSource { +) : ILocalOperations { override suspend fun insert(SearchResultEntity: SearchResultEntity) = searchResultDao.insert(SearchResultEntity) @@ -36,10 +37,6 @@ class LocalDataSource @Inject constructor( return searchResultDao.getAll() } - fun getFavoritesResultById(id: Int): LiveData { - return searchResultDao.getFavoritesResultById(id) - } - fun getAllFavoritesResults() = searchResultDao.getAllFavoritesResults() fun favoriteLastSearchResult(id: Long) { diff --git a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt b/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt index f48a092..92443ea 100644 --- a/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt +++ b/layers/data/src/main/java/com/theteampotato/gifit/data/local/repository/GIFitLocalRepository.kt @@ -1,6 +1,7 @@ package com.theteampotato.gifit.data.local.repository import androidx.lifecycle.LiveData +import com.theteampotato.gifit.data.local.ILocalOperations import com.theteampotato.gifit.data.local.datasource.LocalDataSource import com.theteampotato.gifit.data.local.entity.SearchResultEntity @@ -11,7 +12,7 @@ import kotlinx.coroutines.flow.Flow class GIFitLocalRepository @Inject constructor( private val localDataSource: LocalDataSource -) : BaseLocalRepository { +) : ILocalOperations { override suspend fun insert(SearchResultEntity: SearchResultEntity) = localDataSource.insert(SearchResultEntity) @@ -36,10 +37,6 @@ class GIFitLocalRepository @Inject constructor( return localDataSource.getAll() } - fun getFavoritesResultById(id: Int): LiveData { - return localDataSource.getFavoritesResultById(id) - } - fun getAllFavoritesResults() = localDataSource.getAllFavoritesResults() fun favoriteLastSearchResult(id: Long) { diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt index b1cc956..2ec2b45 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/NetworkImage.kt @@ -18,7 +18,7 @@ fun ProvideImageLoader(content: @Composable () -> Unit) { ImageLoader.Builder(context) .componentRegistry { if (SDK_INT >= 28) - add(ImageDecoderDecoder()) + add(ImageDecoderDecoder(context)) else add(GifDecoder()) }.build() diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt deleted file mode 100644 index da84f87..0000000 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitList.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.theteampotato.gifit.ui.view - -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -import timber.log.Timber - -@Composable -fun GIFitList(items: List) { - LazyColumn { - items(items = items) { item -> - GIFitListElementItem( - item, - Modifier.padding(8.dp) - ) { Timber.i("Clicked item $it") } - } - } -} \ No newline at end of file diff --git a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitListElementItem.kt b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitListElementItem.kt index 550ee33..e5dbec8 100644 --- a/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitListElementItem.kt +++ b/layers/ui/src/main/kotlin/com/theteampotato/gifit/ui/view/GIFitListElementItem.kt @@ -46,8 +46,4 @@ fun GIFitListElementItem( @Preview @Composable fun PreviewGIFitListElementItem() = - GIFitListElementItem( - "Ask Me Anything", - Modifier.padding(8.dp), - {} - ) \ No newline at end of file + GIFitListElementItem("Ask Me Anything", Modifier.padding(8.dp)) {} \ No newline at end of file diff --git a/testing/build.gradle.kts b/testing/build.gradle.kts index 5fd1dc1..d0647ac 100644 --- a/testing/build.gradle.kts +++ b/testing/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { BASE KOTLIN_STANDARD_LIBRARY - implementation(Libraries.Kotlin.Coroutines.Test.TEST) + //implementation(Libraries.Kotlin.Coroutines.Test.TEST) implementation(Libraries.Hilt.Test.TESTING) kapt(Libraries.Hilt.HILT_ANDROID_COMPILER) diff --git a/testing/src/main/java/com/theteampotato/gifit/testing/CoroutineTestRule.kt b/testing/src/main/java/com/theteampotato/gifit/testing/CoroutineTestRule.kt deleted file mode 100644 index 573f7c2..0000000 --- a/testing/src/main/java/com/theteampotato/gifit/testing/CoroutineTestRule.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.theteampotato.gifit.testing - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestCoroutineDispatcher -import kotlinx.coroutines.test.TestCoroutineScope -import kotlinx.coroutines.test.resetMain -import kotlinx.coroutines.test.setMain - -import org.junit.rules.TestWatcher -import org.junit.runner.Description - -/** - * Add this rule to your JUnit 4 tests - */ -@ExperimentalCoroutinesApi -class CoroutineTestRule( - val dispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher() -) : TestWatcher(), TestCoroutineScope by TestCoroutineScope(dispatcher) { - - override fun starting(description: Description?) { - super.starting(description) - Dispatchers.setMain(dispatcher) - } - - override fun finished(description: Description?) { - super.finished(description) - // This could also be just cleanupTestCoroutines() - // But I'm not sure if this works so test it before you use it - dispatcher.cleanupTestCoroutines() - Dispatchers.resetMain() - } -} \ No newline at end of file diff --git a/testing/src/main/java/com/theteampotato/gifit/testing/CoroutinesTestExtension.kt b/testing/src/main/java/com/theteampotato/gifit/testing/CoroutinesTestExtension.kt deleted file mode 100644 index d0e66ac..0000000 --- a/testing/src/main/java/com/theteampotato/gifit/testing/CoroutinesTestExtension.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.theteampotato.gifit.testing - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestCoroutineDispatcher -import kotlinx.coroutines.test.TestCoroutineScope -import kotlinx.coroutines.test.resetMain -import kotlinx.coroutines.test.setMain -/*import org.junit.jupiter.api.extension.AfterEachCallback -import org.junit.jupiter.api.extension.BeforeEachCallback -import org.junit.jupiter.api.extension.ExtensionContext*/ - -/** -* Add this JUnit 5 extension to your test class using -* @JvmField -* @RegisterExtension -* val coroutinesTestExtension = CoroutinesTestExtension() -*/ -@ExperimentalCoroutinesApi -class CoroutinesTestExtension( - private val dispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher() -) /*: BeforeEachCallback, AfterEachCallback, TestCoroutineScope by TestCoroutineScope(dispatcher)*/ { - - /* override fun beforeEach(context: ExtensionContext?) { - Dispatchers.setMain(dispatcher) - } - - override fun afterEach(context: ExtensionContext?) { - cleanupTestCoroutines() - Dispatchers.resetMain() - }*/ -} \ No newline at end of file