|
Revision 9109, 1.2 kB
(checked in by pratik, 7 months ago)
|
Make sure ActiveRecord tests can run individually. Closes #11425 [thechrisoshow, h-lame]
|
| Line | |
|---|
| 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/schema/*.sql files. |
|---|
| 9 |
|
|---|
| 10 |
Make sure that you create database objects with the same user that you specified in |
|---|
| 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, test_sqlite, test_postgresql or any |
|---|
| 18 |
of the other test_ tasks. For more information, checkout the full array of rake |
|---|
| 19 |
tasks with "rake -T" |
|---|
| 20 |
|
|---|
| 21 |
Rake can be found at http://rake.rubyforge.org |
|---|
| 22 |
|
|---|
| 23 |
== Running by hand |
|---|
| 24 |
|
|---|
| 25 |
Unit tests are located in test/cases directory. If you only want to run a single test suite, |
|---|
| 26 |
you can do so with: |
|---|
| 27 |
|
|---|
| 28 |
rake test_mysql TEST=test/cases/base_test.rb |
|---|
| 29 |
|
|---|
| 30 |
That'll run the base suite using the MySQL-Ruby adapter. |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|