Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sphinx/application/sphinx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
versionCode VERSION_CODE.toInteger()
versionName VERSION_NAME

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "chat.sphinx.HiltTestRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}

Expand Down Expand Up @@ -143,6 +143,8 @@ dependencies {
androidTestImplementation testDeps.androidx.core
androidTestImplementation testDeps.androidx.espresso
androidTestImplementation testDeps.androidx.junit
androidTestImplementation testDeps.google.hilt
kaptAndroidTest kaptDeps.google.hilt
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package chat.sphinx

import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
import dagger.hilt.android.testing.HiltTestApplication

class HiltTestRunner : AndroidJUnitRunner() {
override fun newApplication(
cl: ClassLoader,
className: String,
context: Context
): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package chat.sphinx

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.runners.AndroidJUnit4
import chat.sphinx.activitymain.MainActivity
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.junit.runner.RunWith

@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
class MainActivitySmokeTest {

@get:Rule
val hiltRule = HiltAndroidRule(this)

@Before
fun setUp() {
hiltRule.inject()
}

@Test
fun launchMainActivityShowsPrimaryNavigationHost() {
ActivityScenario.launch(MainActivity::class.java).use {
onView(withId(R.id.layout_motion_main)).check(matches(isDisplayed()))
onView(withId(R.id.nav_host_fragment_primary)).check(matches(isDisplayed()))
}
}
}