在 midje 中通过背景重用设置和拆卸
我有许多 midje 事实,它们的设置/拆卸几乎完全相同,但不完全相同。
(against-background [(before :contents (setup!)) (before :contents (data)) (before :facts (set-access)) (after :contents (teardown!)]
(facts "about this thing i am testing "
; ...
))
(against-background [(before :contents (setup!)) (before :contents (data)) (before :facts (set-other-access)) (after :contents (teardown!)]
(facts "about this other thing i am testing "
; ...
))
我想将背景包装成可重用且最好可参数化的东西,以便我可以重用它们,但这样做遇到困难。 Midje 告诉我除上述以外的任何内容都不是预期的背景形式。
I have a number of midje facts that have setup/teardowns that are almost, but not quite, entirely the same.
(against-background [(before :contents (setup!)) (before :contents (data)) (before :facts (set-access)) (after :contents (teardown!)]
(facts "about this thing i am testing "
; ...
))
(against-background [(before :contents (setup!)) (before :contents (data)) (before :facts (set-other-access)) (after :contents (teardown!)]
(facts "about this other thing i am testing "
; ...
))
I would like to wrap the backgrounds into something reusable and preferably paramterizable so I can reuse them, but having trouble doing so. Midje tells me anything other than the above is not the expected background form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Midje 没有能力执行您内置的要求。如果您愿意,请考虑将其添加为此处的问题:
https://github.com/marick /Midje/issues?sort=updated&direction=desc&state=open&page=1
解决方案是创建您自己的宏来执行此操作。 (未经测试)
Midje does not have the ability to do what you ask built into it. If you would like this, consider adding it as an issue here:
https://github.com/marick/Midje/issues?sort=updated&direction=desc&state=open&page=1
A solution is to create your own macro to do this. (untested)