aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/test_case.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add option to set parallel test worker count to the physical core count of ↵Bogdan2018-12-181-2/+7
| | | | | | | | | | | | | | | | | | | | | | the machine (#34735) * Add option to set parallel test worker count to the physical core count of the machine Also, use the physical core count of the machine as the default number of workers, and generate the `test_helper.rb` file with `parallelize(workers: :number_of_processors)` Closes #34734 * Ensure that we always test parallel testing Since #34734 we decided to use the physical core count of the machine as the default number of workers in the parallel testing, we need to ensure that some tests use at least 2 workers because we could run those tests on VM that has only 1 physical core. It also fixes tests failures on the CI since Travis server we are using has only one physical core. See https://travis-ci.org/rails/rails/jobs/469281088#L2352
* use "minitest" consistentlyXavier Noria2018-09-111-2/+2
| | | | | | | | | The name of the minitest library is spelled that way: regular font, and lowercase. Lowercase is used even at the beginning of sentences, see http://docs.seattlerb.org/minitest/ I double-checked this with @zenspider too (thanks!).
* `SetupAndTeardown` has few caveats that breaks libraries:Edouard CHIN2018-04-271-1/+1
| | | | | | | | | | | | | | | | | | - In #32472 I introduced a fix in order for all `after_teardown` method provided by libraries and Rails to run, even if the application's `teardown` method raised an error (That's the default minitest behavior). However this change wasn't enough and doesn't take in consideration the ancestors chain. If a library's module containing an `after_teardown` method get included after the `SetupAndTeardown` module (one example is the [ActiveRecord::TestFixtures module](https://github.com/rails/rails/blob/7d2400ab61c8e3ed95e14d03ba3844e8ba2e36e4/activerecord/lib/active_record/fixtures.rb#L855-L856), then the ancestors of the test class would look something like ```ruby class MyTest < ActiveSupport::TestCase end puts MyTest.ancestors # [MyTest, ActiveSupport::TestCase, ActiveRecord::TestFixtures, ActiveSupport::Testing::SetupAndTeardown] ``` Any class/module in the ancestors chain that are **before** the `ActiveSupport::Testing::SetupAndTeardown` will behave incorrectly: - Their `before_setup` method will get called **after** all regular setup method - Their `after_teardown` method won't even get called in case an exception is raised inside a regular's test `teardown` A simple reproduction script of the problem here https://gist.github.com/Edouard-chin/70705542a59a8593f619b02e1c0a188c - One solution to this problem is to have the `AS::SetupAndTeardown` module be the very first in the ancestors chain. By doing that we ensure that no `before_setup` / `after_teardown` get executed prior to running the teardown callbacks
* Small doc fixesT.J. Schuck2018-04-021-4/+4
| | | | [ci skip]
* Fixes typosDharam Gollapudi2018-02-171-3/+3
| | | Fixes typos
* Add test parallelization to Railseileencodes2018-02-151-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Remove unused requireyuuji.yaginuma2017-11-101-1/+0
| | | | This is no longer used since fd6aaaa.
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-10/+10
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-10/+10
|
* Use `on_load` to trigger commandline processing codeAaron Patterson2016-10-211-0/+2
| | | | We need to use on_load so that plugins will get the same functionality
* Move custom assertion to its proper placeSantosh Wadghule2016-08-271-11/+0
| | | | | | | | ActiveSupport::Testing::Assertions. We have a separate module in which have defined Rails' own custom assertions. So it would be good to keep all custom Rails' assertions in one place i.e. in this module.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-12/+12
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Remove deprecated arguments in assert_nothing_raisedRafael Mendonça França2016-06-131-6/+1
|
* Fix `assert_nothing_raised` deprecation warning formatRyuta Kamizono2016-02-241-2/+3
| | | | | | | | | | | | | | | Before: ``` DEPRECATION WARNING: Passing arguments to assert_nothing_raised is deprecated and will be removed in Rails 5.1. ``` After: ``` DEPRECATION WARNING: Passing arguments to assert_nothing_raised is deprecated and will be removed in Rails 5.1. ```
* add deprecation warning to assert_nothing_raised and changelog entryTara Scherner de la Fuente2016-02-221-1/+5
|
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-1/+1
|
* better docs for ActiveSupport::TestCase#assert_nothing_raisedTara Scherner de la Fuente2016-02-181-2/+5
|
* Extract line filtering to Railties.Kasper Timm Hansen2016-01-091-10/+0
| | | | | | | | | | | | The line filter parsing added to ActiveSupport::TestCase is only half the story to enable line filtering. The other half, of adding the patterns to the options, is done in the Minitest plugin that Railties has. Thus it makes more sense to have the filter in Railties with the other half and all the line filtering tests. Move the filter and extend Active Support in an initializer, so that when users or `rails/all.rb` require `rails/test_unit/railtie` we can still filter by line.
* Improve test runner's Minitest integration.Kasper Timm Hansen2015-06-041-0/+10
| | | | | | | | | | | 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/
* refactor ActiveSupport::TestCase.test_order method with memoizationMehmet Emin İNAÇ2015-05-041-8/+1
|
* Fix incorrect description for `assert_nothing_raised`.Guo Xiang Tan2015-03-241-1/+1
|
* Remove alias for `i_suck_and_my_tests_are_order_dependent`.Guo Xiang Tan2015-03-241-2/+0
|
* introduce `ActiveSupport::Testing::FileFixtures`.Yves Senn2015-01-281-0/+2
| | | | | | 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.
* Remove unneeded `require 'as/deprecation'`claudiob2015-01-041-1/+0
| | | | | Tests should still pass after removing `require 'active_support/deprecation'` from these files since the related deprecations have been removed.
* Change the default test order from `:sorted` to `:random`Rafael Mendonça França2015-01-041-17/+3
|
* Add docs for AS::TestCase::test_orderclaudiob2014-12-181-0/+15
| | | | | | Document `test_order` and `test_order=` from `ActiveSupport::TestCase`. [ci skip]
* edit pass over all warningsXavier Noria2014-10-281-1/+1
| | | | | | | | | | | | | | | This patch uniformizes warning messages. I used the most common style already present in the code base: * Capitalize the first word. * End the message with a full stop. * "Rails 5" instead of "Rails 5.0". * Backticks for method names and inline code. Also, converted a few long strings into the new heredoc convention.
* Define the configuration at Active SupportRafael Mendonça França2014-09-111-10/+7
|
* Default to sorting user's test cases for nowGodfrey Chan2014-09-081-0/+32
| | | | | | | | | | | Goals: 1. Default to :random for newly generated applications 2. Default to :sorted for existing applications with a warning 3. Only show the warning once 4. Only show the warning if the app actually uses AS::TestCase Fixes #16769
* Nobody sucks so nobody should call this awful method nameRafael Mendonça França2014-08-121-0/+4
|
* Remove old setup from AS test caseCarlos Antonio da Silva2014-08-121-5/+0
| | | | | This was added back in Rails 3 on c4a6109286909c394e8c5bfc471a1eb9de245d2b, and is not being used anymore.
* users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent!Akira Matsuda2014-08-121-4/+0
| | | | | Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes everyone's tests order dependent, which should never be done by the framework.
* Revert "Merge pull request #15305 from tgxworld/remove_unnecessary_require"Santiago Pastorino2014-07-301-0/+2
| | | | | | | This reverts commit f632f79b8dcd144408c66a544984b2ba9cf52f87, reversing changes made to 98c7fe87690ca4de6c46e8f69806e82e3f8af42d. Closes #16343
* Stop requiring mocha automaticallyRafael Mendonça França2014-07-191-5/+0
| | | | | | | | | | | We are planning to remove mocha from our test suite because of performance problems. To make this possible we should stop require mocha on ActionSupport::TestCase. This should not affect applications since users still need to add mocha to Gemfile and this already load mocha. Added FIXME notes to place that still need mocha removal
* Remove unnecessary require of Minitest.Guo Xiang Tan2014-05-241-2/+0
| | | | Minitest has already been required when calling Minitest.autorun.
* Add `#travel` and `#travel_to` to AS::TestCasePrem Sichanugrist2013-11-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These methods change current time to the given time or time difference by stubbing `Time.now` and `Date.today` to return the time or date after the difference calculation, or the time or date that got passed into the method respectively. These methods also accept a block, which will return current time back to its original state at the end of the block. Example for `#travel`: Time.now # => 2013-11-09 15:34:49 -05:00 travel 1.day Time.now # => 2013-11-10 15:34:49 -05:00 Date.today # => Sun, 10 Nov 2013 Example for `#travel_to`: Time.now # => 2013-11-09 15:34:49 -05:00 travel_to Time.new(2004, 11, 24, 01, 04, 44) Time.now # => 2004-11-24 01:04:44 -05:00 Date.today # => Wed, 24 Nov 2004 Both of these methods also accept a block, which will return the current time back to its original state at the end of the block: Time.now # => 2013-11-09 15:34:49 -05:00 travel 1.day do User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00 end travel_to Time.new(2004, 11, 24, 01, 04, 44) do User.create.created_at # => Wed, 24 Nov 2004 01:04:44 EST -05:00 end Time.now # => 2013-11-09 15:34:49 -05:00 This module is included in `ActiveSupport::TestCase` automatically.
* rm minitest monkey patchAaron Patterson2013-11-161-17/+0
|
* Use the method provided by minitest to make tests order dependentGuillermo Iguaran2013-11-091-4/+2
|
* fix typo in comment [ci skip].Yves Senn2013-10-281-1/+1
|
* Remove active_support/testing/pending.rb was deprecated.kennyj2013-06-011-2/+0
|
* Require only minitest.Rafael Mendonça França2013-05-221-1/+1
| | | | | minitest/autorun required minitest/spec and we are avoiding to require it.
* Eliminate minitest warningsSam Ruby2013-05-171-1/+1
| | | | https://github.com/seattlerb/minitest/commit/9a57c520ceac76abfe6105866f8548a94eb357b6#L15R8
* Updates to make rails 4 happy with minitest 5:Ryan Davis2013-05-061-3/+21
| | | | | | | | | | + Namespace changes, overhaul of runners. + Internal ivar name changes - Removed a logger globally applied to tests that spew everywhere?!? + Override Minitest#__run to sort tests by name. + Reworked testing isolation to work with the new cleaner architecture. - Removed a bunch of tests that just test minitest straight up. I think these changes were all merged to minitest 4 a long time ago. - Minor report output differences.
* Revert "prevent minitest from printing a --seed run option"Xavier Noria2013-02-241-12/+2
| | | | | | | | | Reason: on a second thought, minitest prints a seed as run option regardless of the test order, and it actually calls srand, so albeit it might be misleading I believe, it is the way it is and should be left that way. This reverts commit c15862ae0cb876d745609170f0f90a9bb9b5e0ae.
* prevent minitest from printing a --seed run optionXavier Noria2013-02-241-2/+12
| | | | See the first FIXME comment in the patch for the rationale.
* Alias refute methods to assert_not and perfer assert_not on testsRafael Mendonça França2012-12-311-1/+10
|
* Inherit from MiniTest::Unit::TestCase instead of MiniTest::SpecRafael Mendonça França2012-12-311-8/+2
|