Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order dependencies in unit tests #362

Closed
sferik opened this issue Jan 23, 2015 · 3 comments · Fixed by #376
Closed

Fix order dependencies in unit tests #362

sferik opened this issue Jan 23, 2015 · 3 comments · Fixed by #376

Comments

@sferik
Copy link
Collaborator

sferik commented Jan 23, 2015

After switching from Test::Unit to Minitest, I started noticing some intermittent build failures. These will typically self-correct by restarting the build. They seem to be caused by an order dependency.

Minitest will force the tests to run in alphabetical order if you add the flag i_suck_and_my_tests_are_order_dependent! but I think it would be better to just fix the order dependency. 😊

There’s a project called minitest-bisect that should make it easier to track down random failures.

@sferik sferik changed the title Fix order dependencies in tests Fix order dependencies in unit tests Jan 23, 2015
@bf4
Copy link
Collaborator

bf4 commented Jan 26, 2015

Sounds good :)

@bf4 bf4 mentioned this issue Feb 19, 2015
@hugopeixoto
Copy link
Contributor

I've tried to track this down. It seems that it is related to global configuration settings.

Some tests do things like SimpleCov.add_filter without cleaning up.
I'm adding the following pattern wherever it seems appropriate:

setup do
  @prev_filters, SimpleCov.filters = SimpleCov.filters, []
end

teardown do
  SimpleCov.filters = @prev_filters
end

Not sure if that's the way to go, but it solves the problem.

hugopeixoto added a commit to hugopeixoto/simplecov that referenced this issue Mar 7, 2015
Some tests were changing global configuration settings
without restoring them afterwards. Fixes simplecov-ruby#362
hugopeixoto added a commit to hugopeixoto/simplecov that referenced this issue Mar 7, 2015
Some tests were changing global configuration settings
without restoring them afterwards. Fixes simplecov-ruby#362
@colszowka
Copy link
Collaborator

Merged and green, thanks a lot for tackling this @hugopeixoto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants