Skip to content

Commit

Permalink
Fix instrumentation test execution with HiltAndroidRule
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaygopinath committed Oct 28, 2024
1 parent ae4f0eb commit 307d327
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ dependencies {
implementation(libs.hilt.android)
kspTest(libs.hilt.compiler)
testImplementation(libs.hilt.testing)
testFixturesImplementation(libs.hilt.testing)
testImplementation(libs.hilt.android)
testFixturesImplementation(libs.hilt.testing)
testFixturesImplementation(libs.hilt.android)

implementation(libs.libphonenumber)
Expand All @@ -102,5 +102,7 @@ dependencies {

androidTestImplementation(libs.bundles.test)
androidTestImplementation(libs.bundles.espresso)
androidTestImplementation(libs.hilt.testing)
androidTestImplementation(libs.hilt.android)
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.matcher.ViewMatchers.withText
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.vinaygopinath.launchchat.Constants
import org.vinaygopinath.launchchat.helpers.AssertionHelper.assertIntentNavigation

@HiltAndroidTest
class MainActivityMenuTest {

@get:Rule
val rule = HiltAndroidRule(this)

@Before
fun setUp() {
launch(MainActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.matcher.ViewMatchers.withId
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.vinaygopinath.launchchat.R
import org.vinaygopinath.launchchat.helpers.AssertionHelper.assertIntentNavigation
import org.vinaygopinath.launchchat.helpers.IntentHelper

@HiltAndroidTest
class MainActivityOpenSignalIntentTest {

@get:Rule
val rule = HiltAndroidRule(this)

@Before
fun setUp() {
launch(MainActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.matcher.ViewMatchers.withId
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.vinaygopinath.launchchat.R
import org.vinaygopinath.launchchat.helpers.AssertionHelper.assertIntentNavigation
import org.vinaygopinath.launchchat.helpers.IntentHelper

@HiltAndroidTest
class MainActivityOpenTelegramIntentTest {

@get:Rule
val rule = HiltAndroidRule(this)

@Before
fun setUp() {
launch(MainActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.matcher.ViewMatchers.withId
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.vinaygopinath.launchchat.R
import org.vinaygopinath.launchchat.helpers.AssertionHelper.assertIntentNavigation
import org.vinaygopinath.launchchat.helpers.IntentHelper

@HiltAndroidTest
class MainActivityOpenWhatsappIntentTest {

@get:Rule
val rule = HiltAndroidRule(this)

@Before
fun setUp() {
launch(MainActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.vinaygopinath.launchchat.R
import org.vinaygopinath.launchchat.helpers.AssertionHelper.assertIntentNavigation
import org.vinaygopinath.launchchat.helpers.IntentHelper

@HiltAndroidTest
class MainActivityPhoneNumberSelectionDialogTest {

@get:Rule
val rule = HiltAndroidRule(this)

@Before
fun setUp() {
launch(MainActivity::class.java)
Expand Down

0 comments on commit 307d327

Please sign in to comment.