问题
Injecting one Steps def into another can rapidly lead to dependency bloat as the amount of re-use among steps defs grows. Furthermore it couples steps defs very tightly to each-other.
There must be a better way. Any suggestions?
Is passing information between steps defs an anti-pattern that should be avoided anyway?
回答1:
If your question is about sharing state between different Step Definition classes, you can do this with Dependency Injection frameworks like Spring. Here's a blog that explains (better than I could paraphrase right here): http://www.thinkcode.se/blog/2017/06/24/sharing-state-between-steps-in-cucumberjvm-using-spring
If you don't want to use Spring, there are other DI frameworks you can use.
来源:https://stackoverflow.com/questions/33713674/what-is-the-best-way-to-pass-information-from-one-steps-def-class-to-another