JBehave maintain data across steps Given/When/Then during a Scenario

余生长醉 提交于 2019-12-01 16:25:17

问题


I have been trying JBehave for sometime and I need to figure out if there exists a way to maintain data across steps during the run of one particular scenario ? I mean is it possible to maintain the state/data during a scenario across the Given/When/Then with out using any state variable under the Step Class.


回答1:


Yes, you can pass an object that maintains the shared state to the different steps.

The Noughts And Crosses example in jbehave core demonstrates this. There's some share state between stories that is maintained in the class WindowControl.

See that the class NoughtsAndCrossesStory that sets up the environment injects an instance of WindowControl to all the steps.



来源:https://stackoverflow.com/questions/9389845/jbehave-maintain-data-across-steps-given-when-then-during-a-scenario

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!