aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit
Commit message (Collapse)AuthorAgeFilesLines
* Avoid running system tests by defaultRobin Dupret2017-03-053-10/+19
| | | | | | | | | | These tests may be expansive so let's only allow users to run them through `bin/rails test:system` or by passing a path to the `test` command. The same applies for `bin/rake test`. Refs #28109.
* Fix run_via[]= backwards compatibility.Kasper Timm Hansen2017-02-211-1/+3
| | | | | | | | | ``` Minitest.run_via[:rails] = true ``` 👆 would break because a simple alias won't catch the second true argument there.
* Merge pull request #26703 from eileencodes/rails_system_testsEileen M. Uchitelle2017-02-202-0/+6
|\ | | | | WIP: Capybara Integration with Rails (AKA System Tests)
| * Refactor config settings to use generated fileeileencodes2017-02-201-13/+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.
| * Don't load ActionSystemTest in productioneileencodes2017-02-201-0/+12
| | | | | | | | | | | | | | | | | | | | By moving to the TestUnit Railtie, and doing the file requirement inside the onload call we can avoid loading ActionSystemTest in production and load it in the test env. This is important for performance reasons - loading up unnecessary files and object is expensive, especially when they should never be used in production.
| * Add generators and ability to run system testseileencodes2017-02-202-0/+6
| | | | | | | | | | | | | | * Generates system test requirements with new Rails app * Includes required default gems in Gemfile for Rails app * Generates a single system test case * Generates a system test case with scaffold
* | Prevent multiple values being set to `run_via`yuuji.yaginuma2017-02-181-5/+29
|/ | | | | When executing the test via rake, since `rake` is set for `run_via`, `ruby` should not be set. Related 2cb6c27310452da11b93d729c3b760ce988106e1
* Collect all file patterns when running multiple rake test tasksDominic Cleal2017-02-041-7/+7
| | | | | | | Replaces the rake_patterns instance variable with simple require, as `autorun` will run tests from all eagerly required test files. Fixes #27801
* add warnings option to test runneryuuji.yaginuma2017-01-241-0/+5
|
* Use `on_load` to trigger commandline processing codeAaron Patterson2016-10-211-0/+8
| | | | We need to use on_load so that plugins will get the same functionality
* Prevent the test framework from being loaded in production modeAaron Patterson2016-10-211-6/+0
| | | | | | | | | | | | The test framework should not be autoloaded in production mode. Before this commit, the testing railtie would extend AS::TestCase. This caused AS::TestCase to be preloaded regardless of the environment in which we were running. This commit just moves the code that adds line filtering support in to the test command where we actually execute the test runner. That allows us to maintain the line runner feature but only load the minimal amount of code we need.
* Use autorun when running via Rake.Kasper Timm Hansen2016-09-251-3/+13
| | | | | | | Makes sure we get support for `Minitest.after_run` hooks and don't accidentally run tests twice. Requires overriding minitest `run` to respect the TESTOPTS variable.
* Revise setting of run_with_rails_extension.Kasper Timm Hansen2016-09-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | The Rails test runner supports three ways to run tests: directly, via rake, or ruby. When Running with Ruby ala `ruby -Itest test/models/post_test.rb` our test file would be evaluated first, requiring `test_helper` and then `active_support/testing/autorun` that would then require the test file (which it hadn't been before) thus reevaluating it. This caused exceptions if using Active Support's declarative syntax. Fix this by shifting around when we set the how we're run to closer mimick the require order. If we're running with `bin/rails test` the test command file is run first and we then set `run_with_rails_extension`, later we hit `active_support/testing/autorun` and do nothing — because we've been run elsewhere. If we at this point haven't set `run_with_rails_extension` we've been running with `ruby` this whole time and thus we set that. We should always trigger `Minitest.autorun` as it doesn't hurt to call it twice. Consolidate the two methods into a single one that better brings out the intent of why they're there.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* revises most Lint/EndAlignment offensesXavier Noria2016-08-071-3/+3
| | | | Some case expressions remain, need to think about those ones.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in railtiesXavier Noria2016-08-061-5/+5
|
* applies new string literal convention in railties/libXavier Noria2016-08-066-17/+17
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* remove unnessary option setting from test runneryuuji.yaginuma2016-04-251-5/+2
| | | | | | | If run the test over the `rake` command, because of the test patterns is passed via `rake_run` method, do not need to be obtained from the argv. This probably fixes #24372.
* [ci skip] Improve comment minitest plugin initialization.Kasper Timm Hansen2016-03-221-2/+4
| | | | | Didn't feel we were clear enough about our motivation for placing Rails first and why we needed to call `load_plugins`.
* Don't get ahead of ourselves.Kasper Timm Hansen2016-03-221-3/+3
| | | | The useless explicit self calls were driving me nuts.
* Set Rails as the first minitest initialized plugin.Kasper Timm Hansen2016-03-221-1/+3
| | | | | | | | | | | When calling `load_plugins` minitest would fill out its extensions, then we'd tackle ourselves on as the last plugin. Because minitest loads plugins in order we will ultimately have the last say on what reporters will be used. Invert that strategy by putting ourselves first and give other plugins plenty of leeway to override our default reporter setup. Fixes #24179.
* make sure `rake test` respects TESTOPTSAaron Patterson2016-02-221-1/+2
| | | | | We should be able to pass options to minitest via TESTOPTS environment variable
* [ci skip] Mention testing fore-runners.Kasper Timm Hansen2016-02-211-0/+2
| | | | Get it? ( ͡° ͜ʖ ͡°)
* use method provided by minitestyuuji.yaginuma2016-02-211-7/+1
| | | | | | | The process of converting `Test` to `String` is already defined in minitest. I think it is better to use that for the consistency of output content. ref: https://github.com/seattlerb/minitest/blob/master/lib/minitest/test.rb#L261..L267
* modify to `error` also abort when specify fail fast optionyuuji.yaginuma2016-02-172-2/+2
|
* test runner, relay minitest information about the error location.Yves Senn2016-02-151-1/+1
| | | | | This is a follow-up to ea70c29 to bring back the assertion error location information provided by minitest.
* Revert "Prefer Minitest's location for test failures."Yves Senn2016-02-151-8/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 0db310586ac3e15be95d2ef27ff40cfa24c05c10. Closes #23686. Conflicts: railties/test/application/test_runner_test.rb It's possible that the `result.location` returned by minitest is outside the test file itself. For example in the case of mocha. This resulted in bad rerun snipptets: ``` bin/rails test app/models/deliveries/delivery.rb:103 ``` Let's always use the first line of the failed test-case in our rerun snippet. We can display the line number of the assertion error elsewhere.
* Fix mixing line filters with Minitest's -n filter.Kasper Timm Hansen2016-02-051-4/+12
| | | | | | | | | | | Previous commit accidentally broke mixing line filters with string -n filter. Fix by checking if it is a string and returning it. We also need to ensure the -n filter carry forward into any other composite filters. Fix by letting the named filter be extractable, so we'll keep this for the next runnable's run.
* Fix line filters running tests from multiple runnables.Kasper Timm Hansen2016-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | `derive_regexp` was written with the assumption that we were run from a blank slate — that if the filter didn't match we might as well return it because it was nil. This isn't the case because minitest calls `run` on every runnable. Which is any subclass of Minitest::Runnable, such as ActiveSupport::TestCase, ActionDispatch::IntegrationTest as well as any inheriting from those. Thus after the first `run` we'd have put in a composite filter in `options[:filter]` making the next `run` create a linked list when it failed to match the regexp and put the composite filter as the head. Every runnable would accumulate more and more of the same filters, which effectively acted like an expanding whitelist and we ran tests from other runnables. Clog the accumulation by returning nil if there's no filter to derive a regexp from. Note: we pass a seed in the tests because Minitest shuffles the runnables to ensure the whitelist is expanded enough that the failure is triggered.
* Don't run all tests when files end in a colon.Kasper Timm Hansen2016-01-181-1/+1
| | | | | | | | | | | | | | If running `bin/rails t test/models/bunny_test.rb:` we'd implicitly run all the tests in the bunny test. I now highly doubt that people would ever put in a line filter without a line *and* want that to mean run all tests in that file. Instead, change regex to require a line digit after the colon, so runs without a line at the end would fail to require the test file. This also has the side benefit of breaking requiring a file with many colons: `bin/rails t test/models/bunny_test.rb:::::::::::::4` Think this means I've had enough colonoscopy to last me through the year :)
* bring back `TEST` env for `rake test`.Yves Senn2016-01-121-1/+6
| | | | | | | Closes #23027. This does not restore complete backwards compatibility. It simply passes the contets of the `TEST` env to the new runner.
* Merge pull request #22808 from y-yagi/do_not_clear_all_reportersKasper Timm Hansen2016-01-111-1/+2
|\ | | | | delete only unnecessary reporter
| * delete only unnecessary reporteryuuji.yaginuma2016-01-111-1/+2
| | | | | | | | | | Reporter that defines its own users at the time of this process are also loaded, to avoid them from being deleted, to delete only the specified to unnecessary reporter.
* | Added multiple line filters support for test runnerSiva Gollapalli2016-01-102-4/+9
| |
* | [ci skip] Clarify some Minitest origins.Kasper Timm Hansen2016-01-091-0/+2
| | | | | | | | | | It might be tough for readers to know why we implement `===`, and where the Regexp in `derive_regexp` came from.
* | Extract line filtering to Railties.Kasper Timm Hansen2016-01-092-0/+69
|/ | | | | | | | | | | | 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.
* Move test coloring closer to where it's used.Kasper Timm Hansen2015-12-231-15/+9
| | | | | | | | | | | Didn't like the constant being at the top of the file, gave it overdue importance. Now that `color_output` expects a result we can shorten some of the flexibility from earlier: * Inline COLOR_CODES constant (keep local variable for readability, but don't need names of colors at run time). * Inline color variable in `color_output`. Looks just as clear without it.
* Remove local variable color.Kasper Timm Hansen2015-12-231-5/+5
| | | | | Focus `color_output`'s intent on coloring output by a result. We aren't meant to pass it arbitrary codes to color output.
* Rename color to color_output.Kasper Timm Hansen2015-12-231-6/+5
| | | | | | The word color is being thrown all around with slightly different meanings. Right now, I understand it. But I'd like to be more immediately clear.
* Remove unused blue color.Kasper Timm Hansen2015-12-231-2/+1
| | | | I got the blues because we aren't coloring any lines blue.
* Color failure line by result code.Kasper Timm Hansen2015-12-231-1/+1
| | | | | | | The static red color wouldn't paint skips in their designated yellow. Use the color name we got from the result label earlier, which marks skips as yellow.
* Rewrite aggregated results suppression.Kasper Timm Hansen2015-12-231-10/+4
| | | | | | | | I should have replaced the summary reporter with a subclass the first time I wrote this. For whatever reason, I didn't. Do it right and slim the methods added to Minitest in the process.
* [ci skip] Clarify why we're clearing reporters.Kasper Timm Hansen2015-12-231-1/+1
| | | | | | Minitest by default includes a summary reporter and a progress reporter. To print colored output, we have to replace the progress reporter.
* Add colored output to the new test reporter.Lucas Mazza2015-12-222-1/+47
|
* display detailed information in inline reportingyuuji.yaginuma2015-12-211-1/+7
| | | | | | | | | | | | | | | | | | | | | The errors message only was not displayed, as if it did not use the inline reporting, modified to also information the method name and the like in error are displayed. ``` # before Failed assertion, no message given. bin/rails test test/models/user_test.rb:5 ``` ``` # after Failure: UserTest#test_the_truth: Failed assertion, no message given. bin/rails test test/models/user_test.rb:5 ```
* show relative path the rerun snippet of test runner in rails engineyuuji.yaginuma2015-12-101-1/+5
| | | | | | | | | | | | | Since the absolute path is not required to re-run the test, modified so that unnecessary information is not displayed. ```ruby # before bin/rails test /path/to/blorgh/test/integration/navigation_test.rb:5 # after bin/rails test test/integration/navigation_test.rb:5 ```
* Fix #22232: rake test tasks exit status codeArkadiusz Fal2015-12-071-1/+3
| | | | | | | The exit status code was not set when tests were fired with `rake`. Now, it is being set and it matches behavior of running tests via `rails` command (`rails test`), so no matter if `rake test` or `rails test` command is used the exit code will be set.
* allow use of minitest-rails gem with test runnerChris Kottom2015-11-301-1/+1
|
* add `bin/test` script to rails pluginyuuji.yaginuma2015-11-281-3/+4
|