summaryrefslogtreecommitdiffhomepage
path: root/android/lib
diff options
context:
space:
mode:
authorJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-01-11 11:49:30 +0100
committerJonatan Rhodin <jonatan.rhodin@mullvad.net>2024-01-11 11:49:30 +0100
commit6c754c3a45fdb93bcb6f9e615c00e70aaa8d90ba (patch)
tree7d25c5e9a9066c7c97517bfbe39469242e0e08e5 /android/lib
parentb5decd12a264c3e37092211eb0951dac6c640670 (diff)
parentb4167469808206ecc7ff2f788befe05e1d7ea57b (diff)
downloadmullvadvpn-6c754c3a45fdb93bcb6f9e615c00e70aaa8d90ba.tar.xz
mullvadvpn-6c754c3a45fdb93bcb6f9e615c00e70aaa8d90ba.zip
Merge branch 'update-to-junit5-droid-569'
Diffstat (limited to 'android/lib')
-rw-r--r--android/lib/billing/build.gradle.kts8
-rw-r--r--android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt14
-rw-r--r--android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt10
-rw-r--r--android/lib/common-test/build.gradle.kts12
-rw-r--r--android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt14
5 files changed, 35 insertions, 23 deletions
diff --git a/android/lib/billing/build.gradle.kts b/android/lib/billing/build.gradle.kts
index 8ecc14f7cd..26cc345556 100644
--- a/android/lib/billing/build.gradle.kts
+++ b/android/lib/billing/build.gradle.kts
@@ -1,5 +1,6 @@
plugins {
id(Dependencies.Plugin.androidLibraryId)
+ id(Dependencies.Plugin.junit5) version Versions.Plugin.junit5
id(Dependencies.Plugin.kotlinAndroidId)
}
@@ -55,11 +56,13 @@ dependencies {
implementation(project(Dependencies.Mullvad.paymentLib))
// Test dependencies
+ testRuntimeOnly(Dependencies.junitEngine)
+
testImplementation(project(Dependencies.Mullvad.commonTestLib))
testImplementation(Dependencies.Kotlin.test)
testImplementation(Dependencies.KotlinX.coroutinesTest)
testImplementation(Dependencies.MockK.core)
- testImplementation(Dependencies.junit)
+ testImplementation(Dependencies.junitApi)
testImplementation(Dependencies.turbine)
androidTestImplementation(project(Dependencies.Mullvad.commonTestLib))
@@ -67,6 +70,7 @@ dependencies {
androidTestImplementation(Dependencies.Kotlin.test)
androidTestImplementation(Dependencies.KotlinX.coroutinesTest)
androidTestImplementation(Dependencies.turbine)
- androidTestImplementation(Dependencies.junit)
+ androidTestImplementation(Dependencies.junitApi)
+ androidTestImplementation(Dependencies.junitEngine)
androidTestImplementation(Dependencies.AndroidX.espressoCore)
}
diff --git a/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt b/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt
index e6f5225740..386932681d 100644
--- a/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt
+++ b/android/lib/billing/src/androidTest/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingRepositoryTest.kt
@@ -34,13 +34,13 @@ import net.mullvad.mullvadvpn.lib.billing.model.BillingException
import net.mullvad.mullvadvpn.lib.billing.model.PurchaseEvent
import net.mullvad.mullvadvpn.lib.common.test.TestCoroutineRule
import net.mullvad.mullvadvpn.lib.common.test.assertLists
-import org.junit.After
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
+import org.junit.jupiter.api.AfterEach
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
+@ExtendWith(TestCoroutineRule::class)
class BillingRepositoryTest {
- @get:Rule val testCoroutineRule = TestCoroutineRule()
private val mockContext: Context = mockk()
private lateinit var billingRepository: BillingRepository
@@ -51,7 +51,7 @@ class BillingRepositoryTest {
private val purchaseUpdatedListenerSlot: CapturingSlot<PurchasesUpdatedListener> =
CapturingSlot()
- @Before
+ @BeforeEach
fun setUp() {
mockkStatic(BILLING_CLIENT_CLASS)
mockkStatic(BILLING_CLIENT_KOTLIN_CLASS)
@@ -66,7 +66,7 @@ class BillingRepositoryTest {
billingRepository = BillingRepository(mockContext)
}
- @After
+ @AfterEach
fun tearDown() {
unmockkAll()
}
diff --git a/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt b/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt
index fe25457e49..21e13d5da8 100644
--- a/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt
+++ b/android/lib/billing/src/test/kotlin/net/mullvad/mullvadvpn/lib/billing/BillingPaymentRepositoryTest.kt
@@ -25,12 +25,12 @@ import net.mullvad.mullvadvpn.model.PlayPurchaseInitError
import net.mullvad.mullvadvpn.model.PlayPurchaseInitResult
import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyError
import net.mullvad.mullvadvpn.model.PlayPurchaseVerifyResult
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
+@ExtendWith(TestCoroutineRule::class)
class BillingPaymentRepositoryTest {
- @get:Rule val testCoroutineRule = TestCoroutineRule()
private val mockBillingRepository: BillingRepository = mockk()
private val mockPlayPurchaseRepository: PlayPurchaseRepository = mockk()
@@ -39,7 +39,7 @@ class BillingPaymentRepositoryTest {
private lateinit var paymentRepository: BillingPaymentRepository
- @Before
+ @BeforeEach
fun setUp() {
mockkStatic(PRODUCT_DETAILS_TO_PAYMENT_PRODUCT_EXT)
diff --git a/android/lib/common-test/build.gradle.kts b/android/lib/common-test/build.gradle.kts
index 3d0ef6c028..6e3fc7c02f 100644
--- a/android/lib/common-test/build.gradle.kts
+++ b/android/lib/common-test/build.gradle.kts
@@ -21,10 +21,20 @@ android {
abortOnError = true
warningsAsErrors = true
}
+
+ packaging {
+ resources {
+ pickFirsts += setOf(
+ // Fixes packaging error caused by: jetified-junit-*
+ "META-INF/LICENSE.md",
+ "META-INF/LICENSE-notice.md"
+ )
+ }
+ }
}
dependencies {
implementation(Dependencies.Kotlin.test)
implementation(Dependencies.KotlinX.coroutinesTest)
- implementation(Dependencies.junit)
+ implementation(Dependencies.junitApi)
}
diff --git a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt
index d04983be26..34d6739119 100644
--- a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt
+++ b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt
@@ -6,22 +6,20 @@ import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
-import org.junit.rules.TestWatcher
-import org.junit.runner.Description
+import org.junit.jupiter.api.extension.AfterEachCallback
+import org.junit.jupiter.api.extension.BeforeEachCallback
+import org.junit.jupiter.api.extension.ExtensionContext
@OptIn(ExperimentalCoroutinesApi::class)
class TestCoroutineRule(val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()) :
- TestWatcher() {
+ BeforeEachCallback, AfterEachCallback {
- override fun starting(description: Description) {
- super.starting(description)
+ override fun beforeEach(var1: ExtensionContext?) {
Dispatchers.setMain(testDispatcher)
}
- override fun finished(description: Description) {
- super.finished(description)
+ override fun afterEach(var1: ExtensionContext?) {
Dispatchers.resetMain()
- // Replacement for cleanupTestCoroutines()
testDispatcher.scheduler.runCurrent()
}
}