Last active
August 1, 2019 18:08
-
-
Save Audhil/4b7d967aef29a4d8c0df820152eca25d to your computer and use it in GitHub Desktop.
Unit Test case - https://proandroiddev.com/unit-tests-with-dagger2-retrofit2-rxjava2-and-mockk-android-1c268fa77957
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 AppRepositoryInjectTest { | |
@Inject | |
lateinit var appAPIs: AppAPIs | |
@Before | |
fun setUp() { | |
val component = DaggerTestAppComponent.builder() | |
.applicationModule(TestApplicationModule(GDelegate())) | |
.build() | |
component.into(this) | |
} | |
@Test | |
fun `my test`() { | |
assertNotNull(appAPIs) | |
/* Given */ | |
every { appAPIs.getForecastTempWithUrl("r") } returns Flowable.just(APIResponse()) | |
/* When */ | |
val result = appAPIs.getForecastTempWithUrl("r") | |
/* Then */ | |
result | |
.test() | |
.assertValue(APIResponse()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment