From 29e4771b22ead2e5bf79fd9aeac5f2fd73cda8e0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:56:35 +0000 Subject: [PATCH 1/3] Update dependency com.google.testparameterinjector:test-parameter-injector to v1.22 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7ab0cc6ee3..2288b09220 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -165,7 +165,7 @@ test_mockk = "io.mockk:mockk:1.14.9" test_konsist = "com.lemonappdev:konsist:0.17.3" test_turbine = "app.cash.turbine:turbine:1.2.1" test_truth = "com.google.truth:truth:1.4.5" -test_parameter_injector = "com.google.testparameterinjector:test-parameter-injector:1.21" +test_parameter_injector = "com.google.testparameterinjector:test-parameter-injector:1.22" test_robolectric = "org.robolectric:robolectric:4.16.1" test_appyx_junit = { module = "com.bumble.appyx:testing-junit4", version.ref = "appyx" } test_composable_preview_scanner = "io.github.sergio-sastre.ComposablePreviewScanner:android:0.8.2" From 4cc9c772646beb8f7d20624da0f552594e996b5a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 15 Apr 2026 08:32:26 +0200 Subject: [PATCH 2/3] Use @TestParameter instead of doing the work manually. --- .../screens/onboarding/OnboardingViewTest.kt | 42 ++++++------------- .../kotlin/extension/DependencyHandleScope.kt | 1 + 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/onboarding/OnboardingViewTest.kt b/features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/onboarding/OnboardingViewTest.kt index c8dcd978c6..c3d1ff6015 100644 --- a/features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/onboarding/OnboardingViewTest.kt +++ b/features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/onboarding/OnboardingViewTest.kt @@ -13,7 +13,8 @@ import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick -import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.testing.junit.testparameterinjector.KotlinTestParameters.namedTestValues +import com.google.testing.junit.testparameterinjector.TestParameter import io.element.android.features.login.impl.R import io.element.android.features.login.impl.login.LoginMode import io.element.android.libraries.architecture.AsyncData @@ -31,8 +32,9 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.junit.runner.RunWith +import org.robolectric.RobolectricTestParameterInjector -@RunWith(AndroidJUnit4::class) +@RunWith(RobolectricTestParameterInjector::class) class OnboardingViewTest { @get:Rule val rule = createAndroidComposeRule() @@ -83,21 +85,11 @@ class OnboardingViewTest { } @Test - fun `when can login with QR code - clicking on sign in manually calls the expected callback - can search account provider`() { - `when can login with QR code - clicking on sign in manually calls the expected callback`( - mustChooseAccountProvider = false, + fun `when can login with QR code - clicking on sign in manually calls the expected callback`( + @TestParameter mustChooseAccountProvider: Boolean = namedTestValues( + "can search account provider" to false, + "cannot search account provider" to true, ) - } - - @Test - fun `when can login with QR code - clicking on sign in manually calls the expected callback - cannot search account provider`() { - `when can login with QR code - clicking on sign in manually calls the expected callback`( - mustChooseAccountProvider = true, - ) - } - - private fun `when can login with QR code - clicking on sign in manually calls the expected callback`( - mustChooseAccountProvider: Boolean, ) { val eventSink = EventsRecorder(expectEvents = false) ensureCalledOnceWithParam(mustChooseAccountProvider) { callback -> @@ -114,21 +106,11 @@ class OnboardingViewTest { } @Test - fun `when cannot login with QR code or create account - clicking on continue calls the sign in callback - can search account provider`() { - `when cannot login with QR code or create account - clicking on continue calls the sign in callback`( - mustChooseAccountProvider = false, + fun `when cannot login with QR code or create account - clicking on continue calls the sign in callback`( + @TestParameter mustChooseAccountProvider: Boolean = namedTestValues( + "can search account provider" to false, + "cannot search account provider" to true, ) - } - - @Test - fun `when cannot login with QR code or create account - clicking on continue calls the sign in callback - cannot search account provider`() { - `when cannot login with QR code or create account - clicking on continue calls the sign in callback`( - mustChooseAccountProvider = true, - ) - } - - private fun `when cannot login with QR code or create account - clicking on continue calls the sign in callback`( - mustChooseAccountProvider: Boolean, ) { val eventSink = EventsRecorder(expectEvents = false) ensureCalledOnceWithParam(mustChooseAccountProvider) { callback -> diff --git a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt index 8a5dfa2c4a..ce5c324ff4 100644 --- a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt +++ b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt @@ -49,6 +49,7 @@ fun DependencyHandlerScope.testCommonDependencies( testImplementation(libs.test.arch.core) testImplementation(libs.test.junit) testImplementation(libs.test.mockk) + testImplementation(libs.test.parameter.injector) testImplementation(libs.test.robolectric) testImplementation(libs.test.truth) testImplementation(libs.test.turbine) From 937973570a5252b8824f2654ab4569a45536a9b6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 15 Apr 2026 08:39:14 +0200 Subject: [PATCH 3/3] Use @TestParameter instead of doing the work manually. --- .../space/impl/root/SpacePresenterTest.kt | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/features/space/impl/src/test/kotlin/io/element/android/features/space/impl/root/SpacePresenterTest.kt b/features/space/impl/src/test/kotlin/io/element/android/features/space/impl/root/SpacePresenterTest.kt index e183de6f27..ba4e10a447 100644 --- a/features/space/impl/src/test/kotlin/io/element/android/features/space/impl/root/SpacePresenterTest.kt +++ b/features/space/impl/src/test/kotlin/io/element/android/features/space/impl/root/SpacePresenterTest.kt @@ -11,6 +11,9 @@ package io.element.android.features.space.impl.root import com.google.common.truth.Truth.assertThat +import com.google.testing.junit.testparameterinjector.KotlinTestParameters.namedTestValues +import com.google.testing.junit.testparameterinjector.TestParameter +import com.google.testing.junit.testparameterinjector.TestParameterInjector import io.element.android.features.invite.api.SeenInvitesStore import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteEvents import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteState @@ -49,8 +52,10 @@ import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.advanceUntilIdle import kotlinx.coroutines.test.runTest import org.junit.Test +import org.junit.runner.RunWith import im.vector.app.features.analytics.plan.JoinedRoom as AnalyticsJoinedRoom +@RunWith(TestParameterInjector::class) class SpacePresenterTest { @Test fun `present - initial state`() = runTest { @@ -259,21 +264,11 @@ class SpacePresenterTest { } @Test - fun `present - accept invite is transmitted to acceptDeclineInviteState`() { - `invite action is transmitted to acceptDeclineInviteState`( - acceptInvite = true, - ) - } - - @Test - fun `present - decline invite is transmitted to acceptDeclineInviteState`() { - `invite action is transmitted to acceptDeclineInviteState`( - acceptInvite = false, - ) - } - - private fun `invite action is transmitted to acceptDeclineInviteState`( - acceptInvite: Boolean, + fun `present - invite action is transmitted to acceptDeclineInviteState`( + @TestParameter acceptInvite: Boolean = namedTestValues( + "accept" to true, + "decline" to false, + ), ) = runTest { val eventRecorder = EventsRecorder() val anInvitedRoom = aSpaceRoom(