一段时间以来,我一直在尝试JBehave,我需要弄清楚是否存在一种在特定情况下运行期间跨步骤维护数据的方法?我的意思是,无需使用即可在给定/何时/然后的场景中维护状态/数据 步骤类下的任何状态变量.
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.
推荐答案是的,您可以将保持共享状态的对象传递给不同的步骤.
Yes, you can pass an object that maintains the shared state to the different steps.
jbehave核心对此进行了演示.在 WindowControl .
The Noughts And Crosses example in jbehave core demonstrates this. There's some share state between stories that is maintained in the class WindowControl.
看到设置环境的NoughtsAndCrossesStory类将WindowControl实例注入所有步骤.
See that the class NoughtsAndCrossesStory that sets up the environment injects an instance of WindowControl to all the steps.
更多推荐
JBehave在场景中跨给定/何时/然后的步骤维护数据
发布评论