To unit test a regular function (that is not suspe...
# android
m
To unit test a regular function (that is not suspended) that returns a Result<T> after a
sequence {
of logical validations (none of which are long running), do I have to use
runTest
in each test case? The result is obtained through a terminal operation on the sequence. I was not using runTest and my tests were always passing locally but failed on the CI. A colleague found a solution using runTest with an Unconfined dispatcher. I am trying to understand why this solved the issue and if it is always needed for dealing with sequence builders that yield a result.
nono 1
e
sequence
doesn't use any
kotlinx.coroutines
dispatchers so it shouldn't be related
do you have a MCVE? you could even try it on Kotlin Playground, like this: https://pl.kotl.in/qJP0qRYK3
m
you are right @ephemient! It was my bad actually. I didn't recall the solution correctly. There was no need for the unconfined dispatcher. However, the runTest was what solved the CI issue. I ended up rewriting the functions as sequences were not really needed. But i still want to get a better understanding of the CI issue. I will work on getting a MCVE. Thank you!