| 1 |
== Creating the test database |
|---|
| 2 |
|
|---|
| 3 |
The default names for the test databases are "activerecord_unittest" and |
|---|
| 4 |
"activerecord_unittest2". If you want to use another database name then be sure |
|---|
| 5 |
to update the connection adapter setups you want to test with in |
|---|
| 6 |
test/connections/<your database>/connection.rb. |
|---|
| 7 |
When you have the database online, you can import the fixture tables with |
|---|
| 8 |
the test/fixtures/db_definitions/*.sql files. |
|---|
| 9 |
|
|---|
| 10 |
Make sure that you create database objects with the same user that you specified in i |
|---|
| 11 |
connection.rb otherwise (on Postgres, at least) tests for default values will fail. |
|---|
| 12 |
|
|---|
| 13 |
== Running with Rake |
|---|
| 14 |
|
|---|
| 15 |
The easiest way to run the unit tests is through Rake. The default task runs |
|---|
| 16 |
the entire test suite for all the adapters. You can also run the suite on just |
|---|
| 17 |
one adapter by using the tasks test_mysql_ruby, test_ruby_mysql, test_sqlite, |
|---|
| 18 |
or test_postresql. For more information, checkout the full array of rake tasks with "rake -T" |
|---|
| 19 |
|
|---|
| 20 |
Rake can be found at http://rake.rubyforge.org |
|---|
| 21 |
|
|---|
| 22 |
== Running by hand |
|---|
| 23 |
|
|---|
| 24 |
Unit tests are located in test directory. If you only want to run a single test suite, |
|---|
| 25 |
or don't want to bother with Rake, you can do so with something like: |
|---|
| 26 |
|
|---|
| 27 |
cd test; ruby -I "connections/native_mysql" base_test.rb |
|---|
| 28 |
|
|---|
| 29 |
That'll run the base suite using the MySQL-Ruby adapter. Change the adapter |
|---|
| 30 |
and test suite name as needed. |
|---|
| 31 |
|
|---|
| 32 |
You can also run all the suites on a specific adapter with: |
|---|
| 33 |
|
|---|
| 34 |
cd test; all.sh "connections/native_mysql" |
|---|
| 35 |
|
|---|