Skip to content

TIL Rails: Errors In Test Cases Creates Floating Test Data #12

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

Merged
merged 1 commit into from
Nov 24, 2015

Conversation

stevenyap
Copy link
Contributor

If an exception is thrown when running your test cases, the test data
created will NOT be rolled back.
This creates "floating" test data in your test database will may impact
other test cases.

The most common solution is to use the gem database_cleaner which
basically clears out the entire test database
whenever you start the test cases.
However, this makes your test cases run slower!
Furthermore, database_cleaner gem also don't address any test data
leakage in your test cases.

The easiest solution is to run rake db:test:prepare in your terminal.
This resets the entire test database so that there are no more floating
test data in your test database.

Every time you have a floating test data issue, you should run rake db:test:prepare
instead of using a slow solution like database_cleaner.

If an exception is thrown when running your test cases, the test data
created will NOT be rolled back.
This creates "floating" test data in your test database will may impact
other test cases.

The most common solution is to use the gem database_cleaner which
basically clears out the entire test database
whenever you start the test cases.
However, this makes your test cases run slower!
Furthermore, database_cleaner gem also don't address any test data
leakage in your test cases.

The easiest solution is to run `rake db:test:prepare` in your terminal.
This resets the entire test database so that there are no more floating
test data in your test database.

Every time you have a floating test data issue, you should run `rake
db:test:prepare`
instead of using a slow solution like database_cleaner.
WayneTng added a commit that referenced this pull request Nov 24, 2015
TIL Rails: Errors In Test Cases Creates Floating Test Data
@WayneTng WayneTng merged commit 4de56cf into master Nov 24, 2015
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 this pull request may close these issues.

2 participants