2004-11-23 20:04:44 -05:00
|
|
|
== Creating the test database
|
|
|
|
|
2010-08-14 01:13:00 -04:00
|
|
|
The default names for the test databases are "activerecord_unittest" and
|
|
|
|
"activerecord_unittest2". If you want to use another database name then be sure
|
|
|
|
to update the connection adapter setups you want to test with in
|
|
|
|
test/connections/<your database>/connection.rb.
|
|
|
|
When you have the database online, you can import the fixture tables with
|
2008-01-21 12:20:51 -05:00
|
|
|
the test/schema/*.sql files.
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2010-08-14 01:13:00 -04:00
|
|
|
Make sure that you create database objects with the same user that you specified in
|
2005-02-23 18:52:40 -05:00
|
|
|
connection.rb otherwise (on Postgres, at least) tests for default values will fail.
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
== Running with Rake
|
|
|
|
|
|
|
|
The easiest way to run the unit tests is through Rake. The default task runs
|
|
|
|
the entire test suite for all the adapters. You can also run the suite on just
|
2010-04-13 17:23:41 -04:00
|
|
|
one adapter by using the tasks test_mysql, test_sqlite3, test_postgresql or any
|
2006-10-05 14:19:24 -04:00
|
|
|
of the other test_ tasks. For more information, checkout the full array of rake
|
|
|
|
tasks with "rake -T"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
Rake can be found at http://rake.rubyforge.org
|
|
|
|
|
|
|
|
== Running by hand
|
|
|
|
|
2010-08-14 01:13:00 -04:00
|
|
|
Unit tests are located in test/cases directory. If you only want to run a single test suite,
|
2007-10-15 02:48:16 -04:00
|
|
|
you can do so with:
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2008-03-28 07:55:01 -04:00
|
|
|
rake test_mysql TEST=test/cases/base_test.rb
|
2010-08-14 01:13:00 -04:00
|
|
|
|
2008-05-03 12:29:47 -04:00
|
|
|
That'll run the base suite using the MySQL-Ruby adapter. Some tests rely on the schema
|
|
|
|
being initialized - you can initialize the schema with:
|
|
|
|
|
|
|
|
rake test_mysql TEST=test/cases/aaa_create_tables_test.rb
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2010-06-17 11:41:39 -04:00
|
|
|
The incantation for running a particular test looks like this
|
2006-07-04 22:54:19 -04:00
|
|
|
|
2010-06-17 11:41:39 -04:00
|
|
|
ruby -w -I"lib:test:test/connections/native_postgresql" test/cases/datatype_test_postgresql.rb -n test_timestamp_with_zone_values_without_rails_time_zone_support
|
2006-07-04 22:54:19 -04:00
|
|
|
|