-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump to 2.6.0 and add testing docs (#608)
* Bump to 2.6.0 and add testing docs * Bump versions * Fix license file conflicts
- Loading branch information
Showing
6 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Unit Testing | ||
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: | ||
- Disable lifecycle awareness of viewmodel observers | ||
- Make state store operations synchronous | ||
- Disable debug checks on viewmodels | ||
- Swap TestCoroutineDispatcher for the Main coroutine dispatcher. | ||
|
||
### JUnit 5 Extension | ||
|
||
Add the `MvRxTestExtension` to your test's companion object. | ||
```kotlin | ||
companion object { | ||
@JvmField | ||
@RegisterExtension | ||
val mvrxTestExtension = MvRxTestExtension() | ||
} | ||
``` | ||
|
||
### JUnit 4 Rule | ||
|
||
Add the `MvRxTestRule` rule to your test. | ||
|
||
```kotlin | ||
@get:Rule | ||
val mvrxRule = MvRxTestRule() | ||
``` |
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
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