Open IvanSyabro opened 2 years ago
With a smaller value for advanceTimeBy()
, it's still not clear why the test doesn't fail on its own without the additional line you suggested. Isn't the coroutine running refreshTitle()
incomplete when the test ends? Maybe I'm not clear on why your suggested line is needed.
In 10 step of coroutines codelab https://developer.android.com/codelabs/kotlin-coroutines#9 user is expected to write unit test which checks for the timeout of
TitleRepository.refreshTitle()
Current version looks next:
It's not clear why this test runs successfully, because if we change value in
advanceTimeBy()
to lower one, for example 4_000, test still completes successfully and throws TitleRefreshError as expected. From this behaviour it may seem that test doesn't work correctly and returns false negative result no matter of timeout value passed toadvanceTimeBy()
.I suggest to add line of code that actually adds value to network, besides, this method is already in the .zip archive example.
And it that case if we change
advanceTimeBy(5_000)
toadvanceTimeBy(4_000)
test will fail. That will show that test really works and doesn't return false negatives