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