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 FragmentTest { | |
protected lateinit var mockWebServer: MockWebServer | |
@Before | |
fun setUp() { | |
mockWebServer = MockWebServer() | |
mockWebServer.start(8080) | |
} |
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(BaseUrlModule::class) | |
@HiltAndroidTest | |
@RunWith(AndroidJUnit4::class) | |
class NewsListFragmentTest { | |
@get:Rule val hiltRule = HiltAndroidRule(this) | |
@Module | |
@InstallIn(ApplicationComponent::class) | |
class FakeBaseUrlModule { |
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
android { | |
defaultConfig { | |
... | |
testInstrumentationRunner "com.company.package.CustomTestRunner" | |
} | |
} |
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 CustomTestRunner : AndroidJUnitRunner() { | |
override fun newApplication(cl: ClassLoader?, appName: String?, context: Context?): Application { | |
return super.newApplication(cl, HiltTestApplication::class.java.name, 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
dependencies { | |
... | |
// Instrumentation tests | |
androidTestImplementation "junit:junit:${Versions.junit}" | |
androidTestImplementation "com.google.truth:truth:${Versions.truth}" | |
androidTestImplementation "org.mockito:mockito-core:${Versions.mockito}" | |
androidTestImplementation "org.mockito:mockito-android:${Versions.mockito}" | |
androidTestImplementation "androidx.test:core:${Versions.androidx_test_core}" | |
androidTestImplementation "androidx.test:runner:${Versions.androidx_test_runner}" | |
androidTestImplementation "androidx.test:rules:${Versions.androidx_test_rules}" |
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
abstract class BaseViewModel<screenState: BaseScreenState, action: BaseAction>(initialState: screenState) : ViewModel() { | |
val intent = Channel<action>(Channel.UNLIMITED) | |
protected val _state = MutableStateFlow(initialState) | |
val state: StateFlow<screenState> get() = _state | |
init { | |
viewModelScope.launch { | |
handleIntents() |
NewerOlder