Last active
June 15, 2023 20:13
-
-
Save tugceaktepe/2d91e44ac90fd77502c587fa750a70d6 to your computer and use it in GitHub Desktop.
Adding mockWebServer for the first time.
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
@UninstallModules( | |
UrlModule::class | |
) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class MainActivityTest { | |
@get:Rule | |
val hiltRule = HiltAndroidRule(this) | |
private val mockWebServer = MockWebServer() | |
@Before | |
fun setUp(){ | |
IdlingRegistry.getInstance().register(TestIdlingResource.countingIdlingResource) | |
mockWebServer.start(8080) | |
} | |
@Test | |
fun screenIsReady(){ | |
val scenario = launchActivity<MainActivity>() | |
onView(withId(R.id.recyclerViewMovies)) | |
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) | |
scenario.close() | |
} | |
@After | |
fun tearDown(){ | |
mockWebServer.shutdown() | |
IdlingRegistry.getInstance().unregister(TestIdlingResource.countingIdlingResource) | |
} | |
@Module | |
@InstallIn(SingletonComponent::class) | |
class FakeBaseUrlModule { | |
@Provides | |
@Singleton | |
fun provideUrl() : String = "http://127.0.0.1:8080" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment