diff --git a/core/build.gradle b/core/build.gradle index fe8b936..e2b19e3 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -9,12 +9,6 @@ java { targetCompatibility = JavaVersion.VERSION_1_8 } -compileKotlin { - kotlinOptions { - freeCompilerArgs += ['-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi'] - } -} - kapt { correctErrorTypes = true } diff --git a/gradlescripts/testoptions.gradle b/gradlescripts/testoptions.gradle index c7b068b..42b9166 100644 --- a/gradlescripts/testoptions.gradle +++ b/gradlescripts/testoptions.gradle @@ -8,6 +8,13 @@ subprojects { module -> showStandardStreams true } } + module.tasks.configureEach { task -> + if (task.taskIdentity.type.toString() == "class org.jetbrains.kotlin.gradle.tasks.KotlinCompile") { + task.kotlinOptions { + freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" + } + } + } } plugins.withId("com.android.application") { diff --git a/network/src/test/java/org/fnives/test/showcase/network/auth/LoginErrorConverterTest.kt b/network/src/test/java/org/fnives/test/showcase/network/auth/LoginErrorConverterTest.kt index d066313..4357ad8 100644 --- a/network/src/test/java/org/fnives/test/showcase/network/auth/LoginErrorConverterTest.kt +++ b/network/src/test/java/org/fnives/test/showcase/network/auth/LoginErrorConverterTest.kt @@ -1,8 +1,9 @@ package org.fnives.test.showcase.network.auth import com.squareup.moshi.JsonDataException +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.test.runBlockingTest +import kotlinx.coroutines.test.runTest import okhttp3.internal.http.RealResponseBody import okio.Buffer import org.fnives.test.showcase.model.session.Session @@ -18,6 +19,7 @@ import retrofit2.Response import java.io.IOException @Suppress("TestFunctionName") +@OptIn(ExperimentalCoroutinesApi::class) class LoginErrorConverterTest { private lateinit var sut: LoginErrorConverter @@ -49,7 +51,7 @@ class LoginErrorConverterTest { @DisplayName("GIVEN 400 error response WHEN parsing login error THEN invalid credentials is returned") @Test - fun code400ResponseResultsInInvalidCredentials() = runBlockingTest { + fun code400ResponseResultsInInvalidCredentials() = runTest { val expected = LoginStatusResponses.InvalidCredentials val actual = sut.invoke { @@ -62,7 +64,7 @@ class LoginErrorConverterTest { @DisplayName("GIVEN successful response WHEN parsing login error THEN successful response is returned") @Test - fun successResponseResultsInSessionResponse() = runBlockingTest { + fun successResponseResultsInSessionResponse() = runTest { val loginResponse = LoginResponse("a", "r") val expectedSession = Session(accessToken = loginResponse.accessToken, refreshToken = loginResponse.refreshToken) val expected = LoginStatusResponses.Success(expectedSession)