In SpecFlow 1.3 there are three methods:
- static members
- ScenarioContext
- ContextInjection
Comments:
static members are very pragmatic and in this case not so evil as we as developers might first think (there is no threading or need for mocking/replacing in step-definitions)
See answer from @Si Keep in this thread
If the constructor of a step definition class needs arguments, Specflow tries to inject these arguments. This can be used to inject the same context into several step-definitions.
See an example here:
https://docs.specflow.org/projects/specflow/en/latest/Bindings/Context-Injection.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…