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
ParameterResolverto inject an object into the test method that can create the object you need to clean up or register it. The extension implementingParameterResolverandAfterEachCallbackcan then use theExtensionContext.Storeto store and retrieve it. If cleanup is all you need, you might not even need to implementAfterEachCallbackbut can wrap your object inCloseableResourcebefore putting it intoExtensionContext.Storewhich will cause it to be cleaned up automatically.