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 { | |
packagingOptions { | |
merge 'META-INF/gradle/incremental.annotation.processors' | |
} | |
} |
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
@IncrementalAnnotationProcessor(IncrementalAnnotationProcessorType.ISOLATING) | |
class YourProcessor1 : AbstractProcessor() { | |
// rest of the code | |
} |
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
override fun getSupportedOptions(): Set<String> { | |
return listOf("org.gradle.annotation.processing.aggregating") | |
} |
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
@Test | |
fun `Should show search button when internet connection is reappeared`() { | |
val testInternetConnectionEmitter = TestObservableEmitter(true) | |
val viewModel = ViewModelBuilder() | |
.withFilters(filters) | |
.withPriceNotifications(priceNotifications) | |
.withInternetConnectionStatusEmitter(testInternetConnectionEmitter) | |
.withIgnoringCallingStatesWithViewModelIsCreated() | |
.build() |
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
@Test | |
fun `Should show search button when internet connection is reappeared`() { | |
val testInternetConnectionEmitter = TestObservableEmitter(true) | |
every { filtersInteractor.getFilters() } returns Single.just(filters) | |
every { priceNotificationsInteractor.getNotificationsFromInMemory() } returns Observable.just(priceNotifications) | |
every { networkConnectionChecker.isInternetAvailable() } returns Observable.create(testInternetConnectionEmitter) | |
val viewModel = createViewModel() | |
testScheduler.triggerActions() | |
clearMocks(screenState) |
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 inner class ViewModelBuilder { | |
fun withLoadingData(): ViewModelBuilder { | |
// For RxJava it would be every { someInteractor.loadSomething() } returns Single.never() | |
coEvery { someInteractor.loadSomething() } coAnswers { | |
delay(1_000) | |
"result is not important" | |
} | |
return 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
@Test | |
fun `Should show content state if user clicks on retry button after loading data with error`() = runTest { | |
val throwable = Throwable() | |
val viewModel = ViewModelBuilder() | |
.withDataLoadedWithError(throwable) | |
.build(testScheduler) | |
//Replaced with Cases | |
Cases(viewModel) |
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
internal inner class Cases(private val viewModel: SomeViewModel) { | |
fun nowDataIsLoadedSuccessfully(dataToLoad: String): Cases { | |
coEvery { someInteractor.loadSomething() } returns dataToLoad | |
return this | |
} | |
fun userClicksOnRetryButton(): Cases { | |
viewModel.onRetryButtonClicked() | |
return 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
class SomeViewModelTest { | |
private val someInteractor: SomeInteractor = mockk(relaxed = true) | |
private val dataToLoad: String = "Data to load" | |
@Before | |
fun setUp() { | |
clearAllMocks() | |
} |
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 SomeViewModelTest { | |
private lateinit var someViewModel: SomeViewModel | |
private val someInteractor: SomeInteractor = mockk(relaxed = true) | |
private val dataToLoad: String = "Data to load" | |
@Before | |
fun setUp() { | |
clearAllMocks() | |
} |
NewerOlder