如何告诉 rspec 在没有挂起测试输出的情况下运行? [英] How to tell rspec to run without pending tests output?
问题描述
有没有办法(也许是一些关键)告诉 rspec 跳过挂起的测试并且不打印有关它们的信息?
Is there a way (maybe some key) to tell rspec to skip pending tests and don't print information about them?
我有一些自动生成的测试,比如
I have some auto generated tests like
pending "add some examples to (or delete) #{__FILE__}"
我运行bundle exec rspec spec/models --format documentation"并得到如下内容:
I run "bundle exec rspec spec/models --format documentation" and get somethin like this:
Rating
allows to rate first time
disallow to rate book twice
Customer
add some examples to (or delete) /home/richelieu/Code/first_model/spec/models/customer_spec.rb (PENDING: No reason given)
Category
add some examples to (or delete) /home/richelieu/Code/first_model/spec/models/category_spec.rb (PENDING: No reason given)
......
我想保留这些文件,因为我稍后会更改它们,但现在我想要输出如下:
I want to keep this files, cause I gonna change them later, but for now I want output like:
Rating
allows to rate first time
disallow to rate book twice
Finished in 0.14011 seconds
10 examples, 0 failures, 8 pending
推荐答案
看一看 标签 -
你可以在你的测试文件中做这样的事情
You could do something like this in your test file
describe "the test I'm skipping for now" do
it "slow example", :skip => true do
#test here
end
end
然后像这样运行你的测试:
and run your tests like this:
bundle exec rspec spec/models --format documentation --tag ~skip
其中 ~
字符排除带有以下标记的所有测试,在本例中为 skip
where the ~
character excludes all tests with the following tag, in this case skip
这篇关于如何告诉 rspec 在没有挂起测试输出的情况下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!