Does anybody have any tips on how to run coroutine...
# spring
g
Does anybody have any tips on how to run coroutines with spring and reactor context? Right now I've gotten my service level code to work with `
Copy code
val reactorContext = coroutineContext[ReactorContext.Key]!!.context.asCoroutineContext()
but if I try to write a unit-test for this I fail with a nullpointerException since I guess the coroutineContext[ReactorContext.Key] is populated from the context given by spring/the controller layer? ?
I access the coroutineContext like this because I am accessing Context-variables in suspend-functions
s
If it’s just for a unit test, you can add a mock context yourself:
Copy code
runBlocking(context = myMockContext) { ... }
👍 1