We use JUnit5 for unit testing and there is a ThreadLocal in a dependency library that we would like to pre-set to different values for certain unit tests. We are using ktor and for some tests it seems that the ThreadLocal loses its value (presumably due to resuming coroutines?).
Is there some way to configure the scope to restore the ThreadLocal value for a given test? I have found resources for how to restore them outside of a unit test scenario, but not sure how to translate that across into a JUnit5 extension. I'd prefer to avoid the boilerplate of a wrapper function in every such test method.