To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / lib / plugins / acts_as_versioned / RUNNING_UNIT_TESTS @ 1298:4f746d8966dd

History | View | Annotate | Download (1.6 KB)

1
== Creating the test database
2

    
3
The default name for the test databases is "activerecord_versioned". If you 
4
want to use another database name then be sure to update the connection 
5
adapter setups you want to test with in test/connections/<your database>/connection.rb. 
6
When you have the database online, you can import the fixture tables with 
7
the test/fixtures/db_definitions/*.sql files.
8

    
9
Make sure that you create database objects with the same user that you specified in i
10
connection.rb otherwise (on Postgres, at least) tests for default values will fail.
11

    
12
== Running with Rake
13

    
14
The easiest way to run the unit tests is through Rake. The default task runs
15
the entire test suite for all the adapters. You can also run the suite on just
16
one adapter by using the tasks test_mysql_ruby, test_ruby_mysql, test_sqlite, 
17
or test_postresql. For more information, checkout the full array of rake tasks with "rake -T"
18

    
19
Rake can be found at http://rake.rubyforge.org
20

    
21
== Running by hand
22

    
23
Unit tests are located in test directory. If you only want to run a single test suite, 
24
or don't want to bother with Rake, you can do so with something like:
25

    
26
   cd test; ruby -I "connections/native_mysql" base_test.rb
27
   
28
That'll run the base suite using the MySQL-Ruby adapter. Change the adapter
29
and test suite name as needed.
30

    
31
== Faster tests
32

    
33
If you are using a database that supports transactions, you can set the
34
"AR_TX_FIXTURES" environment variable to "yes" to use transactional fixtures.
35
This gives a very large speed boost. With rake:
36

    
37
  rake AR_TX_FIXTURES=yes
38

    
39
Or, by hand:
40

    
41
  AR_TX_FIXTURES=yes ruby -I connections/native_sqlite3 base_test.rb