You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Affected Device(s) [e.g. Samsung Galaxy s10 with Android 9.0]
Describe the Bug:
Any class that uses MainCoroutinesRule doesn't actually run the test. If you put the line assertThat(-1, `is`(0)) in any class that uses MainCoroutinesRule it would pass.
Expected Behavior: assertThat(-1, `is`(0)) should assert and fail
Proposed Solution:
The following code should change from:
@ExperimentalCoroutinesApi
class MainCoroutinesRule : TestRule, TestCoroutineScope by TestCoroutineScope() {
private val testCoroutinesDispatcher = TestCoroutineDispatcher()
override fun apply(base: Statement?, description: Description?) = object : Statement() {
override fun evaluate() {
Dispatchers.setMain(testCoroutinesDispatcher)
cleanupTestCoroutines()
Dispatchers.resetMain()
}
}
}
to this:
@ExperimentalCoroutinesApi
class MainCoroutinesRule : TestRule, TestCoroutineScope by TestCoroutineScope() {
private val testCoroutinesDispatcher = TestCoroutineDispatcher()
override fun apply(base: Statement?, description: Description?) = object : Statement() {
override fun evaluate() {
Dispatchers.setMain(testCoroutinesDispatcher)
try {
base?.evaluate()
} finally {
cleanupTestCoroutines()
Dispatchers.resetMain()
}
}
}
}
The text was updated successfully, but these errors were encountered:
ArturoKuang
changed the title
Bug causing test to run properly
Bug causing test to not run properly
Feb 20, 2021
Please complete the following information:
Describe the Bug:
Any class that uses MainCoroutinesRule doesn't actually run the test. If you put the line
assertThat(-1, `is`(0))
in any class that uses MainCoroutinesRule it would pass.Expected Behavior:
assertThat(-1, `is`(0))
should assert and failProposed Solution:
The following code should change from:
to this:
The text was updated successfully, but these errors were encountered: