ViewModelTest

open class ViewModelTest

Base class for ViewModel testing.

Sample test:

class SampleViewModelTest : ViewModelTest() {

    val mockViewState: SampleViewState = mockk()

    lateinit var viewModel: SampleViewModel

    @Before
    fun setUp() {
        viewModel = spyk(SampleViewModel(mockViewState), recordPrivateCalls = true)
    }

    @Test
    fun `when ... then ...`() {
        // GIVEN
        ...

        // WHEN
        ...

        // THEN
        ...
    }

}

Constructors

ViewModelTest
Link copied to clipboard
fun ViewModelTest()

Functions

equals
Link copied to clipboard
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
open fun hashCode(): Int
toString
Link copied to clipboard
open fun toString(): String

Properties

coroutineScopeRule
Link copied to clipboard
@ExperimentalCoroutinesApi()
var coroutineScopeRule: CoroutineScopeRule
Swap coroutine dispatcher with the one that is executed immediately.
instantTaskExecutorRule
Link copied to clipboard
val instantTaskExecutorRule: InstantTaskExecutorRule
Swap background android executor with the one that executes task synchronously.
rxJavaRule
Link copied to clipboard
var rxJavaRule: RxSchedulerRule
Swap RxJava schedulers with the ones that are executed immediately.