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

Tests should not depend on state of previous tests #15

Open
mitalia opened this issue Nov 19, 2012 · 2 comments
Open

Tests should not depend on state of previous tests #15

mitalia opened this issue Nov 19, 2012 · 2 comments
Labels

Comments

@mitalia
Copy link
Contributor

mitalia commented Nov 19, 2012

The tests are currently written in such a way as to depend on the success of previous tests in order to ensure the database is in the proper state. Currently, I am having problems running tests multiple times, as they do not clean up properly. This situation is is undesirable for several reasons:

  1. Tests should always be able to be run stand-alone with no dependencies, this is the point of unit tests.

  2. SBT can run tests in a parallelized fashion, but only if they are isolated. This is especially problematic for our tests since they may refer to the same tables/database schemas. So even if each test makes no assumptions and uses fixtures to set up the database properly, it could still fail if another test "stomps" all of the data it just loaded.

To remedy these:

  1. Fixtures must be created that can put the database into an expected state and then always clean up after the test, even on failure (using try, catch, finally)

  2. For "real" databases, each test should take place in a randomly created schema or alternatively use randomly created table names. Whichever is easier.

  3. SQLite should be modified to use a randomized file name

@lcdavidson
Copy link

Rework is in progress now.

@mitalia
Copy link
Contributor Author

mitalia commented Nov 19, 2012

This probably needs a little more investigation before we dive right in.

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

No branches or pull requests

2 participants