This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScreenshotRule( | |
private val screenshoter: Paparazzi, | |
) : TestRule { | |
val layoutInflater: LayoutInflater | |
get() = paparazzi.layoutInflater | |
val context: Context | |
get() = paparazzi.context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalCoroutinesApi | |
@UninstallModules( | |
UrlProviderModule::class, | |
CacheControlModule::class | |
) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class BaseFragmentTest { | |
@get:Rule val hiltRule = HiltAndroidRule(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IdlingRegistry.getInstance().register(OkHttp3IdlingResource.create("okhttp", okHttp)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
launchFragmentInHiltContainer<FixturesFragment> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.company.package"> | |
<application> | |
<activity | |
android:name=".HiltTestActivity" | |
android:exported="false" /> | |
</application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AndroidEntryPoint | |
class HiltTestActivity : AppCompatActivity() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T : Fragment> launchFragmentInHiltContainer( | |
fragmentArgs: Bundle? = null, | |
@StyleRes themeResId: Int = R.style.SomeTheme, | |
fragmentFactory: FragmentFactory? = null, | |
crossinline action: Fragment.() -> Unit = {} | |
) { | |
val startActivityIntent = Intent.makeMainActivity( | |
ComponentName( | |
ApplicationProvider.getApplicationContext(), | |
HiltTestActivity::class.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MockServerDispatcher { | |
/** | |
* Return ok response from mock server | |
*/ | |
internal inner class RequestDispatcher : Dispatcher() { | |
override fun dispatch(request: RecordedRequest): MockResponse { | |
return when (request.path) { | |
"/fixtures" -> MockResponse().setResponseCode(200).setBody(getJsonContent("fixtures_feed.json")) | |
"/news" -> MockResponse().setResponseCode(200).setBody(getJsonContent("news_response.json")) | |
else -> MockResponse().setResponseCode(400) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun getJsonContent(fileName: String): String { | |
return InputStreamReader(this.javaClass.classLoader!!.getResourceAsStream(fileName)).use { it.readText() } | |
} |
NewerOlder