How do I pass test generated values to AfterEachCallback #3613
-
Hello, I want to pass the values which was generated during the test phase to the AfterEachCallback extension where I need to then cleanup that value. Since my Tests runs parallel, I also want to be thread safe, as it should not clean up value for test which are not completed. Also, I did not find a way to pass the value to AfterEachCallback extension, can someone help ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You can use a |
Beta Was this translation helpful? Give feedback.
You can use a
ParameterResolver
to inject an object into the test method that can create the object you need to clean up or register it. The extension implementingParameterResolver
andAfterEachCallback
can then use theExtensionContext.Store
to store and retrieve it. If cleanup is all you need, you might not even need to implementAfterEachCallback
but can wrap your object inCloseableResource
before putting it intoExtensionContext.Store
which will cause it to be cleaned up automatically.