DBC User wrote:
I have a model and I am trying to do the testing. So my test code is
something like the following
in this I am expecting the test to run against the development
database as only development database has the table. But when I ran,
it is failing because the test table is not found. Why is model
testing is pointing to test database anyway?
Because manual and automated tests should use different databases.
When you manually test, you need a generally sloppy set of records to noodle around with. Suppose you set up a given Person record, such as "Mr. Frootloop". Each time you change the code and manually test, you want the same record to come back in the same state as you left it.
You should run your automated tests much more often than you manually test. Your automated should have an exact set of data fixtures, and you don't need the tests to die just because you manually changed a record. So you need your tests to erase the entire database each time they run.
Put these rules together, and you need two databases. Your "manual test fixture", Mr Frootloop, will not disappear just because you ran the automated tests.
Tip: Configure the automated tests to run automatically, each time you change the code. Then get in the habit of saving your files deliberately, and trying to predict the result of each test run. If you guess wrong, you can always Undo your last edit until the tests pass again. This is a lot better than endlessly debugging!