Improvements to setup/setup_once ordering and exception handling #1

merged 5 commits into from Jun 12, 2011

2 participants


Sequence of changes to make ordering of setups relative to setup_onces (and teardowns relative to teardown_onces) more intuitively correct, and improve exception handling.

Given the complexity of the logic, it may be worthwhile adding more in-depth unit tests now or soon. Let me know your thoughts.

harob added some commits Jun 9, 2011
@harob harob Changing scope's test running algorithm to recursively walk down from…
… the outermost context to the innermost.

This ensures that setup/setup_once and teardown/teardown_once blocks will be run in an intuitive (alternating) order.
@harob harob Adding exception handling to intermediate contexts when running tests. 9673b23
@harob harob Fixing test running to run the teardown_once block whenever the last …
…actual test in a given context is run, even if there are subsequent empty contexts.
@harob harob Merge remote-tracking branch 'upstream/master' c7ade11
@harob harob Updating Scope test for setup_once/setup ordering changes. c2fc56e

I wonder if it's worth it to have every context have a default empty setup and teardown proc so we don't have all of these trailing "if outer_context.teardown_once" everywhere. What do you think?


A slight improvement would be add the short circuit "return @name_of_last_test if defined? (@name_of_last_test).

It would also be nice to explain strategically, why this method is necessary. I think you can get rid of these break statements if you use "find" instead of "each".


Thanks harob, this is awesome. Pulling it in. Have a look at the tweaks I suggested when you get a chance.

@philc philc merged commit fc50872 into ooyala:master Jun 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment