chop-dbhi / dataexpress

[NOT MAINTAINED] DataExpress is a simple, Scala-based cross database ETL toolkit supporting Postgres, MySql, Oracle, SQLServer, and Sqlite
http://dataexpress.research.chop.edu
BSD 2-Clause "Simplified" License
72 stars 9 forks source link

Tests should not depend on state of previous tests #15

Open mitalia opened 11 years ago

mitalia commented 11 years ago

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 commented 11 years ago

Rework is in progress now.

mitalia commented 11 years ago

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