Rspec 标签和过滤器 - 过滤器的多个值?
我有一个测试套件,可以跨软件应用程序的多个版本运行。我希望能够标记那些根据不同版本而变化的测试,以便我设置的过滤器仅运行针对该特定版本的测试。
我正在寻找类似的东西:
describe "the magic page", :version=>["all-magic", "some_magic"]
it "exists!"
end
describe "the magic page", :version=>["no-magic"]
it "does not exist!"
end
Rspec.configure do |config|
this_version= some_version_parameter_passed_in || "no_magic"
config.filter_run :version includes this_version
end
显然,这不起作用,但它应该让您了解我正在努力实现的目标。
I have a test suite that runs across several versions of a software application. I'd like to be able to tag those tests that vary based on different versions so that the filters I have set up only run the tests for this particular version.
I'm looking for something like:
describe "the magic page", :version=>["all-magic", "some_magic"]
it "exists!"
end
describe "the magic page", :version=>["no-magic"]
it "does not exist!"
end
Rspec.configure do |config|
this_version= some_version_parameter_passed_in || "no_magic"
config.filter_run :version includes this_version
end
Obviously, that doesn't work, but it should give you an idea of what I'm trying to accomplish.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您可以使用 Rspec 来做到这一点。查看文档< /a>,然后尝试这样的操作:
然后要使用 magic 标签运行测试,您可以使用以下命令:
或者您可以编辑您的
.rspec
:这对您有用吗?
You can actually do this with Rspec. Take a look at the docs, and try something like this:
Then to run the tests with the magic tag you can use the command:
Or you can edit your
.rspec
:Does this work for you?
您可以在过滤器中使用 lambda,如下所示:
所以您可以执行类似
Or 的操作,仅使用正确的 :versions 运行测试(我认为这就是您正在寻找的),
You can use lambdas in your filter like this:
So you could do something like
Or to only run tests with the correct :versions (I think this is what you're looking for),