diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountTestRule.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountTestRule.kt index 333f4cde8809..6496f82e0793 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountTestRule.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountTestRule.kt @@ -9,24 +9,21 @@ import org.junit.jupiter.api.extension.BeforeEachCallback import org.junit.jupiter.api.extension.ExtensionContext class AccountTestRule : BeforeEachCallback { - - private val partnerAccount: String? private val client = SimpleMullvadHttpClient(InstrumentationRegistry.getInstrumentation().targetContext) + private val partnerAuth: String? = + InstrumentationRegistry.getArguments().getString(PARTNER_AUTH, null) + lateinit var validAccountNumber: String + lateinit var invalidAccountNumber: String - val validAccountNumber: String - val invalidAccountNumber: String - - init { + override fun beforeEach(context: ExtensionContext) { InstrumentationRegistry.getArguments().also { bundle -> - partnerAccount = bundle.getString(PARTNER_AUTH) - - if (partnerAccount != null) { + if (partnerAuth != null) { validAccountNumber = client.createAccount() client.addTimeToAccountUsingPartnerAuth( accountNumber = validAccountNumber, daysToAdd = 1, - partnerAuth = partnerAccount + partnerAuth = partnerAuth ) } else { validAccountNumber = @@ -38,6 +35,4 @@ class AccountTestRule : BeforeEachCallback { bundle.getRequiredArgument(INVALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY) } } - - override fun beforeEach(context: ExtensionContext) {} }