docs/testing.md
When writing unit tests for view models it is helpful to force the backing coroutines to run synchronously, as well as to have control over the state of the viewmodel.
Mavericks provides support for managing this in both JUnit 4 and 5 tests via the optional mavericks-testing artifact.
To use, apply either the test rule or test extension, configured to your needs via the appropriate properties. See the kdoc on the respective classes for the most up to date documentation on usage.
By default, the rule/extension will:
Add the MvRxTestExtension to your test's companion object.
@RegisterExtension
val mavericksTestExtension = MavericksTestExtension()
Add the MvRxTestRule rule to your test.
@get:Rule
val mavericksRule = MavericksTestRule()