aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/RUNNING_UNIT_TESTS
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-04 23:19:17 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-04 23:47:03 +0100
commit253bb6b9260938ed673e2c0059d729cffff4a523 (patch)
treecf8aa429645a0c73d32e8fe0eecf62a536488bdd /activerecord/RUNNING_UNIT_TESTS
parentcdce7ff191313bd99a31d26ddca5a5c8be766695 (diff)
downloadrails-253bb6b9260938ed673e2c0059d729cffff4a523.tar.gz
rails-253bb6b9260938ed673e2c0059d729cffff4a523.tar.bz2
rails-253bb6b9260938ed673e2c0059d729cffff4a523.zip
Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
Diffstat (limited to 'activerecord/RUNNING_UNIT_TESTS')
-rw-r--r--activerecord/RUNNING_UNIT_TESTS46
1 files changed, 14 insertions, 32 deletions
diff --git a/activerecord/RUNNING_UNIT_TESTS b/activerecord/RUNNING_UNIT_TESTS
index b3d376772e..bc4faa488c 100644
--- a/activerecord/RUNNING_UNIT_TESTS
+++ b/activerecord/RUNNING_UNIT_TESTS
@@ -1,43 +1,25 @@
-== Creating the test database
+== Configure databases
-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 within
-test/connections/<your database>/connection.rb.
-When you have the database online, you can import the fixture tables with
-the test/schema/*.sql files.
+Copy test/config.example.yml to test/config.yml and edit as needed. Or just run the tests for
+the first time, which will do the copy automatically and use the default (sqlite3).
-Make sure that you create database objects with the same user that you specified in
-connection.rb otherwise (on Postgres, at least) tests for default values will fail.
+You can build postgres and mysql databases using the build_postgresql and build_mysql rake tasks.
-== Running with Rake
+== Running the tests
-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
-one adapter by using the tasks test_mysql, test_sqlite3, test_postgresql or any
-of the other test_ tasks. For more information, checkout the full array of rake
-tasks with "rake -T"
+You can run a particular test file from the command line, e.g.
-Rake can be found at http://rake.rubyforge.org
+ $ ruby test/cases/base_test.rb
-== Running by hand
+To run a specific test:
-Unit tests are located in test/cases directory. If you only want to run a single test suite,
-you can do so with:
+ $ ruby test/cases/base_test.rb -n test_something_works
- rake test_mysql TEST=test/cases/base_test.rb
+You can run with a database other than the default you set in test/config.yml, using the ARCONN
+environment variable:
-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:
+ $ ARCONN=postgresql ruby test/cases/base_test.rb
- rake test_mysql TEST=test/cases/aaa_create_tables_test.rb
- rake mysql:build_databases
-
-To setup the testing environment for PostgreSQL use this command:
-
- rake postgresql:build_databases
-
-The incantation for running a particular test looks like this
-
- rake test TEST=test/cases/datatype_test_postgresql.rb TESTOPTS="-n test_timestamp_with_zone_values_without_rails_time_zone_support"
+You can run all the tests for a given database via rake:
+ $ rake test_postgresql