在RSpec中,可以使用skip
关键字来标记测试集合,以指示不运行该集合中的测试。
以下是一个示例:
RSpec.describe "My Test Collection" do
it "runs this test" do
expect(1 + 1).to eq(2)
end
# 使用skip关键字标记不运行的测试
it "skips this test", skip: true do
expect(1 + 2).to eq(3)
end
it "runs this test again" do
expect(2 + 2).to eq(4)
end
end
在上面的示例中,第一个和第三个测试将会被运行,但第二个测试将被跳过。
另外,还可以使用xdescribe
来标记整个测试集合不运行,或者使用xit
来标记单个测试不运行。例如:
xdescribe "My Test Collection" do
it "runs this test" do
expect(1 + 1).to eq(2)
end
it "skips this test" do
expect(1 + 2).to eq(3)
end
it "runs this test again" do
expect(2 + 2).to eq(4)
end
end
在这个示例中,整个测试集合将被跳过,因此其中的所有测试都不会运行。
上一篇:不预览情况下打印rdlc