提交 0ce117fa 编写于 作者: A Arthur Nogueira Neves 提交者: GitHub

Merge pull request #26515 from grosser/grosser/after_run

support minitest after_run
* Run `Minitest.after_run` hooks when running `rails test`.
*Michael Grosser*
* Run `before_configuration` callbacks as soon as application constant
inherits from `Rails::Application`.
......
require "rails/test_unit/minitest_plugin"
if defined?(ENGINE_ROOT)
$: << File.expand_path("test", ENGINE_ROOT)
$LOAD_PATH << File.expand_path("test", ENGINE_ROOT)
else
$: << File.expand_path("../../test", APP_PATH)
$LOAD_PATH << File.expand_path("../../test", APP_PATH)
end
exit Minitest.run(ARGV)
require "minitest/autorun"
......@@ -12,7 +12,7 @@ def teardown
teardown_app
end
test "truth" do
test "simple successful test" do
app_file "test/unit/foo_test.rb", <<-RUBY
require 'test_helper'
......@@ -26,6 +26,38 @@ def test_truth
assert_successful_test_run "unit/foo_test.rb"
end
test "after_run" do
app_file "test/unit/foo_test.rb", <<-RUBY
require 'test_helper'
Minitest.after_run { puts "WORLD" }
Minitest.after_run { puts "HELLO" }
class FooTest < ActiveSupport::TestCase
def test_truth
assert true
end
end
RUBY
result = assert_successful_test_run "unit/foo_test.rb"
assert_equal ["HELLO", "WORLD"], result.scan(/HELLO|WORLD/) # only once and in correct order
end
test "simple failed test" do
app_file "test/unit/foo_test.rb", <<-RUBY
require 'test_helper'
class FooTest < ActiveSupport::TestCase
def test_truth
assert false
end
end
RUBY
assert_unsuccessful_run "unit/foo_test.rb", "Failed assertion"
end
test "integration test" do
controller "posts", <<-RUBY
class PostsController < ActionController::Base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册