spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.36k stars 38.03k forks source link

Support alternate `testContextHolder` for `TestContextManager` #32898

Closed Kantis closed 2 months ago

Kantis commented 4 months ago

Kotest is a Kotlin based testing framework. We execute tests on coroutines, which may (or may not) execute on different threads. As such, the TestContextManager created for a certain class cannot reliably store the TestContext as a ThreadLocal.

We recently received an issue regarding this.

Could you consider providing the means to provide other storage alternatives?

Simply letting us inject or access the ThreadLocal should be sufficient, since we could then add it as a coroutine context element which the coroutine machinery would then take care of.

sbrannen commented 3 months ago

Hi @Kantis,

Simply letting us inject or access the ThreadLocal should be sufficient, since we could then add it as a coroutine context element which the coroutine machinery would then take care of.

Would it be sufficient for Kotest if we introduce a new TestContextManager constructor (or constructors) that allow you to supply a ThreadLocal<TestContext> testContextHolder?

spring-projects-issues commented 2 months ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues commented 2 months ago

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.