aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_help.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use testing lazy-load hooks:Edouard CHIN2018-07-041-10/+11
| | | | - In order to avoid loading classes prematurely, let's use lazy load hooks that are now provided with each test case
* Add test parallelization to Railseileencodes2018-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides both a forked process and threaded parallelization options. To use add `parallelize` to your test suite. Takes a `workers` argument that controls how many times the process is forked. For each process a new database will be created suffixed with the worker number; test-database-0 and test-database-1 respectively. If `ENV["PARALLEL_WORKERS"]` is set the workers argument will be ignored and the environment variable will be used instead. This is useful for CI environments, or other environments where you may need more workers than you do for local testing. If the number of workers is set to `1` or fewer, the tests will not be parallelized. The default parallelization method is to fork processes. If you'd like to use threads instead you can pass `with: :threads` to the `parallelize` method. Note the threaded parallelization does not create multiple database and will not work with system tests at this time. parallelize(workers: 2, with: :threads) The threaded parallelization uses Minitest's parallel exector directly. The processes paralleliztion uses a Ruby Drb server. For parallelization via threads a setup hook and cleanup hook are provided. ``` class ActiveSupport::TestCase parallelize_setup do |worker| # setup databases end parallelize_teardown do |worker| # cleanup database end parallelize(workers: 2) end ``` [Eileen M. Uchitelle, Aaron Patterson]
* `create_fixtures` doesn't work since at least ↵Edouard CHIN2017-12-111-4/+0
| | | | | | | a94220b66c9e4890007f66b092b25f8a64a19d31: - The namespacing should be `ActiveRecord::FixtureSet` - I might be missing something but I'm not sure why `create_fixtures` is useful for nowaday (unless for testing rails internal /shrug) and since it's been that long it wasn't working I think it should be fine to just fire it
* [Railties] require_relative => requireAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 618268b4b9382f4bcf004a945fe2d85c0bd03e32
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* * Don't eagerly require Rails' minitest plugin.Kasper Timm Hansen2017-07-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
* [Railties] require => require_relativeAkira Matsuda2017-07-011-2/+2
|
* Friendly maintain schema failureKir Shatrov2017-04-301-1/+6
|
* Remove unnecessary system test codeeileencodes2017-03-031-13/+0
| | | | | | | It turns out that we don't need to require system tests in the railties test helper so we can remove it. If you're using system tests they will be loaded by inheriting from ActionDispatch::SystemTestCase and the routes will be loaded by ActionDispatch::IntegrationTest.
* Only load SystemTestCase if Puma is definedyuuji.yaginuma2017-02-271-2/+2
| | | | | | | | SystemTestCase supports only Puma, and always load puma's file. https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/system_testing/server.rb#L1 For that reason, the case of use Capybara but do not use Puma, it will cause an error. So we need to check about Puma is defined as well.
* Only load SystemTestCase if Capybara is definedeileencodes2017-02-211-5/+10
| | | | | | | | For applications that are upgrading or applications that are choosing to skip system testing Capbyara will not be available. SystemTestCase and friends shoud only be loaded if Capbyara is defined. Fixes #28094
* Move and rename system testseileencodes2017-02-201-2/+2
| | | | | | | | | | * Move system tests back into Action Pack * Rename `ActionSystemTest` to `ActionDispatch::SystemTestCase` * Remove private base module and only make file for public `SystemTestCase` class, name private module `SystemTesting` * Rename `ActionSystemTestCase` to `ApplicationSystemTestCase` * Update corresponding documentation and guides * Delete old `ActionSystemTest` files
* Refactor config settings to use generated fileeileencodes2017-02-201-1/+1
| | | | | | | | | | | | | | | | | | | Originally I had set up system testing to have one configuration option to be set in the test environment. After thinking it over I think a generated class on app creation would be best. The reason for this is Capybara has a ton of configuration options that I'm sure some folks want to use. Thinking about how we handle screenshots, database transactions, and a whole bunch of other settings it would be better for users to be able to turn all of that on and off. When an app or scaffold is generated a `test/system_test_helper.rb` test helper will be generated as well. This will contain the class for tests to inherit from `ActionSystemTestCase` which will inherit from `ActionSystemTest::Base`. Here is where users can change the test driver, remove the screenshot helper, and add their additional Capybara configuration.
* Turn system testing into it's own gem and renameeileencodes2017-02-201-2/+2
| | | | | | | | | | Renames `Rails::SystemTestCase` to `ActionSystemTest` and moves it to a gem under the Rails name. We need to name the class `ActionSystemTestCase` because the gem expects a module but tests themselves expect a class. Adds MIT-LICENSE, CHANGELOG, and README for the future.
* Appease Rubocopeileencodes2017-02-201-1/+1
| | | | Rubocop / code climate don't like single quotes and prefer doubles.
* Add skeleton for Rails::SystemTestCaseeileencodes2017-02-201-0/+8
| | | | | | | This skelton is the bare minimum to get system tests to actually run in an application. This of course doesn't yet actually run a test but it is enough for `bin/rails test:system` to attempt to run files in `test/system` that inherit from `Rails::SystemTestCase`.
* Avoid documenting private or external classesRobin Dupret2017-02-071-4/+8
| | | | | | | | | | | | | | | | There are a lot of monkey patches inside the code base but there's no need to document external constants so let's remove them from the documentation Also, since there are monkey patches for some test cases classes, there were sometimes both documented and sneaked under the wrong section in the sidebar. Finally, for future references, the `active_support/vendor` folder has been originally ignored in https://git.io/vDqfA but no longer exists. [ci skip]
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* applies new string literal convention in railties/libXavier Noria2016-08-061-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add `:nodoc:` for internal testing methods [ci skip]Robin Dupret2015-07-281-2/+2
|
* inline test runner check into `as/testing/autorun.rb`.Yves Senn2015-06-111-4/+1
| | | | | This makes it possible to easily get the runner working with existing setups that rely on `active_support/testing/autorun.rb`.
* Improve test runner's Minitest integration.Kasper Timm Hansen2015-06-041-1/+5
| | | | | | | | | | | This also adds free mix and matching of directories, files and lines filters. Like so: bin/rails test models/post_test.rb test/integration models/person_test.rb:26 You can also mix in a traditional Minitest filter: bin/rails test test/integration -n /check_it_out/
* Use `def before_setup` instead of `setup do`eileencodes2015-05-021-2/+4
| | | | | | | | | | | | | | `setup do` creates unnecessary allocations of proc objects in test callbacks. This prevents that from happening and results in faster code. Originally I had done this as `def setup` and all Railties tests passed. See 044f9ab. Later it was reported there was an issue with this that caused routes in tests to be nil because devs don't generally call `super` in their test setups. Because of that I reverted the commit until I could find a suitble replacement. `before_setup` esentially does the same thing but without the requirement that applications call `super` in their test setups.
* Revert "Use `def setup` instead of `setup do`"eileencodes2015-03-201-4/+2
| | | | This reverts commit 044f9ab7a4d6646ddce4560bb83b58cdc0baa751.
* Move minitest pluginArthur Neves2015-03-181-6/+1
| | | | | | | Minitest Rails plugin should be loaded on test_help, so we report errors even when not running from the runner. Also fix the backtrace
* Use `def setup` instead of `setup do`eileencodes2015-03-121-2/+4
| | | | | `setup do` creates unnecessary allocations of proc objects in callbacks. This prevents that from happening and results in faster code.
* introduce `ActiveSupport::Testing::FileFixtures`.Yves Senn2015-01-281-0/+1
| | | | | | It's a thin layer to provide easy access to sample files throughout test-cases. This adds the directory `test/fixtures/files` to newly generated applications.
* Require action_controller before any other action_controller fileRafael Mendonça França2014-04-101-0/+1
| | | | | | This will load properly the loading hooks. Closes rails/sass-rails#205
* Automatically maintain test database schemaJon Leighton2014-01-021-0/+2
| | | | | | | | | | | | | | * Move check from generated helper to test_help.rb, so that all applications can benefit * Rather than just raising when the test schema has pending migrations, try to load in the schema and only raise if there are pending migrations afterwards * Opt out of the check by setting config.active_record.maintain_test_schema = false * Deprecate db:test:* tasks. The test helper is now fully responsible for maintaining the test schema, so we don't need rake tasks for this. This is also a speed improvement since we're no longer reloading the test database on every call to "rake test".
* Change all `MiniTest` to `Minitest` since, `MiniTest` namespace has been ↵Vipul A M2013-12-181-1/+1
| | | | | | renamed to `Minitest` Ref: https://github.com/seattlerb/minitest/blob/master/History.txt
* BACKTRACE environment variable to show unfiltered backtraces.Yves Senn2013-11-041-1/+3
| | | | | | | | | | | We used to support the `BACKTRACE` environment variable but when we switched to MiniTest it got removed: f9382cd7948 This commit adds back the functionality to show the unfiltered backtrace when needed. This also works when you run your tests with `rake`: * `BACKTRACE=1 bin/rake test` * `BACKTRACE=1 ruby -Itest ...`
* Added generated unit test for generator generator and new test:generators ↵Josef Šimánek2013-07-161-0/+1
| | | | rake task included in test:all rake task.
* Don't configure Turn output, we aren't using it since 3.2.0Guillermo Iguaran2013-01-071-7/+0
|
* Don't require 'turn' from rails/test_helpAaron Suggs2013-01-071-5/+2
| | | | | | | | | | | | If 'turn' is in the Gemfile with `:require => nil`, Rails should respect that. This supports the case where 'turn' may or may not be required depending on different developers' preference or environment. E.g., you require turn for local testing, but not on your CI server by putting this in `test/test_helper.rb`: require 'turn' if ENV['TURN']
* Add active_support/testing/autorunRafael Mendonça França2012-12-311-1/+1
| | | | | minitest/autorun load minitest/spec polluting the global namespace with the DSL that we don't want on Rails
* Rename "Fixtures" class to "FixtureSet"Alexey Muranov2012-10-071-2/+2
| | | | Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`. Instances of this class normally hold a collection of fixtures (records) loaded either from a single YAML file, or from a file and a folder with the same name. This change make the class name singular and makes the class easier to distinguish from the modules like `ActiveRecord::TestFixtures`, which operates on multiple fixture sets, or `DelegatingFixtures`, `::Fixtures`, etc., and from the class `ActiveRecord::Fixture`, which corresponds to a single fixture.
* use Rails backtrace in testsFrancesco Rodriguez2012-10-051-0/+4
|
* update test_help to config properly turn natural language optionFrancesco Rodriguez2012-07-061-1/+4
| | | | | | | | | | | | Last versions of Turn don't monkey patch MiniTest to setup the natural language option. Here is an [example](https://github.com/TwP/turn/blob/master/try/test_autorun_minitest.rb#L3). This patches the following behaviour: $ rake test:units `<top (required)>': undefined method `use_natural_language_case_names=' for MiniTest::Unit:Class (NoMethodError)
* Remove IdentityMapCarlos Antonio da Silva2012-03-131-4/+0
|
* if turn available then ↵Vishnu Atrai2012-01-071-4/+1
| | | | MiniTest::Unit.respond_to?(:use_natural_language_case_names=) available
* Merge pull request #4360 from rafaelfranca/patch-1Aaron Patterson2012-01-061-13/+6
|\ | | | | Remove more references to Test::Unit
| * MiniTest is always defined in this caseRafael Mendonça França2012-01-061-8/+6
| |
| * Test::Unit::Util::BacktraceFilter is never definedRafael Mendonça França2012-01-061-5/+0
| |
* | require minitest rather than test/unitAaron Patterson2012-01-061-1/+1
|/
* do not require a file that is not usedAaron Patterson2012-01-051-2/+0
|
* Modified how to handle if ActiveRecord is defined.Yasuo Honda2011-09-301-1/+1
|
* Removed AS core_ext/kernel/requires as it's not used and is bad practice.Josh Kalderimis2011-05-231-1/+0
|
* make turn a soft dependency. generate a Gemfile that contains turn and ↵Aaron Patterson2011-04-081-3/+7
| | | | require turn if it is available
* Moved Turn activation/dependency to railtiesDavid Heinemeier Hansson2011-03-311-0/+8
|
* Merge remote branch 'rails/master' into identity_mapEmilio Tagua2010-12-201-11/+0
|\ | | | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/associations/association_proxy.rb activerecord/lib/active_record/autosave_association.rb activerecord/lib/active_record/base.rb activerecord/lib/active_record/persistence.rb