Chuck Stein
10/19/2022, 1:48 PMTestScope
(e.g. to inject into the class under test), then you must call runTest
on that scope, because there can only be one TestScope
instance in a test. But it doesn't say why? Doing this causes my runTest
block to timeout and fail the test, because the class I injected the TestScope
into uses it to shareIn
, which never completes. So my question is what are the repercussions if I disregard this rule and instead call runTest(testScope.testScheduler)
(which passes), rather than testScope.runTest
as the docs suggest (which fails). Or, if I should really be using the recommended way, how do I get it to not time out for my use case?Dmitry Khalanskiy [JB]
10/19/2022, 2:09 PMChuck Stein
10/19/2022, 3:07 PMtestScope.runTest
for my test case, but my class uses testScope.backgroundScope
instead of the base testScope
, that doesn't violate the guidelines of "only one TestScope
for the whole test"?
Also, can you point me to what the downsides are if one violates this rule?Dmitry Khalanskiy [JB]
10/20/2022, 10:20 AMbackgroundScope
is not a TestScope
, so the rule is not violated.
For now, the downsides are, you will lose the exceptions that happen in coroutines in a TestScope
on which runTest
is not called. Further down the road, new downsides may appear. We simply don't support the case of more than one TestScope
.