Can I skip a test if another test fails?

Let's say I have 2 tests:

describe "Data Processor" do it "should parse simple sample data correctly" do ... end it "should parse complex sample data correctly" do ... end end 

Is there a way to use Rspec so that the second test Rspec on the first? The reason I ask is because I use Watchr , and the second test takes a little longer. If the first test fails, the second most likely will fail. They are not really dependent on each other, but it is a waste of time to run the second test if the first fails.

I can skip the test with Ctrl C in Watchr , but I'm wondering if there is a better way. Could not find anything through Google.

+4
source share
1 answer

Sometimes I add this line to my .rspec :

 --fail-fast 

which is a command line flag telling rspec to exit after the first failure. This may not be exactly what you want; it does not bind two specific examples together, but rather terminates the entire test suite when something fails.

But when I hammer a new bit of code with autotest / guard / watchr, I like to enable this because I want to work with only one failure at a time. Much faster.

+3
source

Source: https://habr.com/ru/post/1392145/


All Articles