Note that there are some explanatory texts on larger screens.

plurals
  1. POrspec: how can I continue test after first failure
    primarykey
    data
    text
    <p>I am using rspec to system test a device. The device is modular so that any number of sub-devices may be connected to a test rig. There are many places where I want to write tests that will loop over the connected of sub-devices and run the same test on each device. </p> <p>Basically, this is what I am trying to do:</p> <pre><code>before(:all) @tool = discover_sub_devices() @tool.sub_devices.should == exp_sub_device_list end describe "some sub device tests" do @tool.sub_devices.each do |dev| it "should succeed at doing things" do dev.do_thing.should == success end end end </code></pre> <p>Unfortunately this does not work. I get errors saying @tool is nill and does not contain a class <code>sub_devices</code> before the tests even run. So the tests are being parsed before the <code>before(:all)</code> block runs. </p> <p>One way I can make it work is by putting the loop inside of the <code>it</code> block. Like this:</p> <pre><code>it "should succeed at doing things" do @tool.sub_devices.each do |dev| dev.do_thing.should == success    end end </code></pre> <p>The problem with doing it this way is that I really want to test all the sub-devices even if the first one fails. I want to see a report of exactly how many sub devices had failures. This code will break out as soon as one fails and not test the rest.</p> <p>I realize this is probably not a normal use case for rspec but it would be very convenient for our testing situation if I could make this work.</p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload