JBehave 在场景期间跨步骤 Give/When/Then 维护数据
我已经尝试 JBehave 一段时间了,我需要弄清楚是否存在一种方法可以在一个特定场景的运行期间跨步骤维护数据?我的意思是是否可以在给定/何时/然后的场景中维护状态/数据而不使用 Step Class 下的任何状态变量。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以将维护共享状态的对象传递给不同的步骤。
jbehave core 演示了这一点。在类 WindowControl。
请注意,设置环境的 NoughtsAndCrossesStory 类将 WindowControl 的实例注入到所有步骤中。
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.