Is there a good way to debug order dependent test failures in RSpec (RSpec2)?

I wouldn't say I have a good answer, and I'd love to here some better solutions than mine. That said The only real technique I have for debugging these issues is adding a global (via spec_helper) hook for printing some aspect of database state (my usual culprit) before and after each test (conditioned to check if I care or not). A recent example was adding something like this to my spec_helper.

Rb Spec::Runner. Configure do |config| config. Before(:each) do $label_count = Label.

Count end config. After(:each) do label_diff = Label. Count - $label_count $label_count = Label.

Count puts "#{self.class. Description} #{description} altered label count by #{label_diff}" if label_diff! = 0 end end.

I wouldn't say I have a good answer, and I'd love to here some better solutions than mine. That said... The only real technique I have for debugging these issues is adding a global (via spec_helper) hook for printing some aspect of database state (my usual culprit) before and after each test (conditioned to check if I care or not). A recent example was adding something like this to my spec_helper.rb.

Spec::Runner. Configure do |config| config. Before(:each) do $label_count = Label.

Count end config. After(:each) do label_diff = Label. Count - $label_count $label_count = Label.

Count puts "#{self.class. Description} #{description} altered label count by #{label_diff}" if label_diff! = 0 end end.

Thanks for the answer, but it doesn't help me since the software I'm testing doesn't have a database, and the order dependent failures aren't so predictable that a print statement this general would help me :-( – mmrobins May 20 at 4:05.

We have a single test in our Continuous Integration setup that globs the spec/ directory of a Rails app and runs each of them against each other. Takes a lot of time but we found 5 or 6 dependencies that way.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions