我写功能测试,需要进行依赖于先前测试结果的测试。假设我有一个按钮,点击该按钮会打开一个窗口,在其中存在一些功能。也就是说,为了检查这个功能,我需要首先检查按钮的正确操作(即,是否打开窗口或功能是否正常)。因此,我需要做到如果测试在按钮点击时失败,则不运行测试以检查功能窗口。单独编写测试对我来说不是一个选项。我希望看到像这样的内容:
describe "some tests" do
open_result = nil
it "should check work button" do
click_to_button()
open_result = window_opened?
open_result.should == true
end
if open_result
describe "Check some functional" do
it "should check first functional"
it "should check second functional"
end
end
end
我知道这种方法不适用于rspec。这只是我想要看到的简单描述。使用rspec可以实现吗?如果不行,是否有其他方法(gems等)?