Parallel execution and ThreadLocal variables #2268
-
Context: Question: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Threads are reused. How exactly will depend whether you use JUnit 4, JUnit 5 or TestNG. To share state between steps within a single scenario, it is recommended that you use dependency injection. Cucumber will ensure that each scenario has its own isolated object graph to work on. As long as you don't use static variables, or leak your state into a shared context or external system that should work just fine, |
Beta Was this translation helpful? Give feedback.
Threads are reused. How exactly will depend whether you use JUnit 4, JUnit 5 or TestNG.
To share state between steps within a single scenario, it is recommended that you use dependency injection. Cucumber will ensure that each scenario has its own isolated object graph to work on. As long as you don't use static variables, or leak your state into a shared context or external system that should work just fine,