Skip to content

Commit

Permalink
+ Add a method so that code can be run around a particular test case …
Browse files Browse the repository at this point in the history
…(tenderlove)

[git-p4: depot-paths = "//src/minitest/dev/": change = 6739]
  • Loading branch information
zenspider committed Nov 9, 2011
1 parent 562ed8c commit 01dc766
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/minitest/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def run runner
@passed = nil
self.setup
self.run_setup_hooks
self.__send__ self.__name__
self.run_test self.__name__
result = "." unless io?
@passed = true
rescue *PASSTHROUGH_EXCEPTIONS
Expand All @@ -977,6 +977,8 @@ def run runner
result
end

alias :run_test :__send__

def initialize name # :nodoc:
@__name__ = name
@__io__ = nil
Expand Down
32 changes: 32 additions & 0 deletions test/test_minitest_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,38 @@ def test_filter_backtrace_unit_starts
assert_equal ex, fu
end

def test_run_test
tc = Class.new(MiniTest::Unit::TestCase) do
attr_reader :foo

def run_test name
@foo = "hi mom!"
super
@foo = "okay"
end

def test_something
assert_equal "hi mom!", foo
end
end

Object.const_set(:ATestCase, tc)

@tu.run %w[--seed 42]

expected = "Run options: --seed 42
# Running tests:
.
Finished tests in 0.00
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
"
assert_report expected
end

def test_run_error
tc = Class.new(MiniTest::Unit::TestCase) do
def test_something
Expand Down

0 comments on commit 01dc766

Please sign in to comment.