上级 fe98d212
* Run `Minitest.after_run` hooks when running `rails test`.
*Michael Grosser*
* Run `before_configuration` callbacks as soon as application constant
inherits from `Rails::Application`.
......
......@@ -6,4 +6,6 @@
$LOAD_PATH << File.expand_path("../../test", APP_PATH)
end
exit Minitest.run(ARGV)
result = Minitest.run(ARGV)
Minitest.class_variable_get(:@@after_run).reverse_each(&:call)
exit result
......@@ -26,6 +26,24 @@ 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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册