rails/activerecord/RUNNING_UNIT_TESTS.rdoc

61 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

== Setup
If you don't have an environment for running tests, read
https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#setting-up-a-development-environment
== Running the Tests
To run a specific test:
$ bundle exec ruby -Itest test/cases/base_test.rb -n method_name
To run a set of tests:
$ bundle exec ruby -Itest test/cases/base_test.rb
You can also run tests that depend upon a specific database backend. For
example:
$ bundle exec rake test:sqlite3
Simply executing <tt>bundle exec rake test</tt> is equivalent to the following:
$ bundle exec rake test:mysql2
Introduce adapter for Trilogy, a MySQL-compatible DB client The [Trilogy database client][trilogy-client] and corresponding [Active Record adapter][ar-adapter] were both open sourced by GitHub last year. Shopify has recently taken the plunge and successfully adopted Trilogy in their Rails monolith. With two major Rails applications running Trilogy successfully, we'd like to propose upstreaming the adapter to Rails as a MySQL-compatible alternative to Mysql2Adapter. [trilogy-client]: https://github.com/github/trilogy [ar-adapter]: https://github.com/github/activerecord-trilogy-adapter Co-authored-by: Aaron Patterson <tenderlove@github.com> Co-authored-by: Adam Roben <adam@roben.org> Co-authored-by: Ali Ibrahim <aibrahim2k2@gmail.com> Co-authored-by: Aman Gupta <aman@tmm1.net> Co-authored-by: Arthur Nogueira Neves <github@arthurnn.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Ashe Connor <kivikakk@github.com> Co-authored-by: Brandon Keepers <brandon@opensoul.org> Co-authored-by: Brian Lopez <seniorlopez@gmail.com> Co-authored-by: Brooke Kuhlmann <brooke@testdouble.com> Co-authored-by: Bryana Knight <bryanaknight@github.com> Co-authored-by: Carl Brasic <brasic@github.com> Co-authored-by: Chris Bloom <chrisbloom7@github.com> Co-authored-by: Cliff Pruitt <cliff.pruitt@cliffpruitt.com> Co-authored-by: Daniel Colson <composerinteralia@github.com> Co-authored-by: David Calavera <david.calavera@gmail.com> Co-authored-by: David Celis <davidcelis@github.com> Co-authored-by: David Ratajczak <david@mockra.com> Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Eileen Uchitelle <eileencodes@gmail.com> Co-authored-by: Enrique Gonzalez <enriikke@gmail.com> Co-authored-by: Garrett Bjerkhoel <garrett@github.com> Co-authored-by: Georgi Knox <georgicodes@github.com> Co-authored-by: HParker <HParker@github.com> Co-authored-by: Hailey Somerville <hailey@hailey.lol> Co-authored-by: James Dennes <jdennes@gmail.com> Co-authored-by: Jane Sternbach <janester@github.com> Co-authored-by: Jess Bees <toomanybees@github.com> Co-authored-by: Jesse Toth <jesse.toth@github.com> Co-authored-by: Joel Hawksley <joelhawksley@github.com> Co-authored-by: John Barnette <jbarnette@github.com> Co-authored-by: John Crepezzi <john.crepezzi@gmail.com> Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Nunemaker <nunemaker@gmail.com> Co-authored-by: Jonathan Hoyt <hoyt@github.com> Co-authored-by: Katrina Owen <kytrinyx@github.com> Co-authored-by: Keeran Raj Hawoldar <keeran@gmail.com> Co-authored-by: Kevin Solorio <soloriok@gmail.com> Co-authored-by: Leo Correa <lcorr005@gmail.com> Co-authored-by: Lizz Hale <lizzhale@github.com> Co-authored-by: Lorin Thwaits <lorint@gmail.com> Co-authored-by: Matt Jones <al2o3cr@gmail.com> Co-authored-by: Matthew Draper <matthewd@github.com> Co-authored-by: Max Veytsman <mveytsman@github.com> Co-authored-by: Nathan Witmer <nathan@zerowidth.com> Co-authored-by: Nick Holden <nick.r.holden@gmail.com> Co-authored-by: Paarth Madan <paarth.madan@shopify.com> Co-authored-by: Patrick Reynolds <patrick.reynolds@github.com> Co-authored-by: Rob Sanheim <rsanheim@gmail.com> Co-authored-by: Rocio Delgado <rocio@github.com> Co-authored-by: Sam Lambert <sam.lambert@github.com> Co-authored-by: Shay Frendt <shay@github.com> Co-authored-by: Shlomi Noach <shlomi-noach@github.com> Co-authored-by: Sophie Haskins <sophaskins@github.com> Co-authored-by: Thomas Maurer <tma@github.com> Co-authored-by: Tim Pease <tim.pease@gmail.com> Co-authored-by: Yossef Mendelssohn <ymendel@pobox.com> Co-authored-by: Zack Koppert <zkoppert@github.com> Co-authored-by: Zhongying Qiao <cryptoque@users.noreply.github.com>
2023-03-20 20:17:09 +00:00
$ bundle exec rake test:trilogy
$ bundle exec rake test:postgresql
$ bundle exec rake test:sqlite3
Using the SQLite3 adapter with an in-memory database is the fastest way
to run the tests:
$ bundle exec rake test:sqlite3_mem
There should be tests available for each database backend listed in the {Config
File}[rdoc-label:label-Config+File]. (the exact set of available tests is
defined in +Rakefile+)
There are some performance tests for the encryption system that can be run with.
$ rake test:encryption:performance:mysql2
$ rake test:integration:active_job:postgresql
$ rake test:encryption:performance:sqlite3
These performance tests are not executed as part of the regular testing tasks.
== Config File
If +test/config.yml+ is present, then its parameters are obeyed; otherwise, the
parameters in +test/config.example.yml+ are.
You can override the +connections:+ parameter in either file using the +ARCONN+
(Active Record CONNection) environment variable:
$ ARCONN=postgresql bundle exec ruby -Itest test/cases/base_test.rb
Or
$ bundle exec rake test:postgresql TEST=test/cases/base_test.rb
You can specify a custom location for the config file using the +ARCONFIG+
environment variable.