minitest/design_rationale.rb

53 lines
1.9 KiB
Ruby
Raw Normal View History

# Specs: # Equivalent Unit Tests:
###############################################################################
Oh god... here we go. Minitest 5: Deaths in the family: ! MiniTest.runner is dead. No more manager objects. ! MiniTest::Unit#record is dead. Use a Reporter instance instead. ! MiniTest::Unit._run_* is dead. Runnable things are responsible for their own runs. ! MiniTest::Unit.output is dead. No more centralized IO. Major (oft incompatible) changes: ! Renamed MiniTest to Minitest. Your pinkies will thank me. ! Removed MiniTest::Unit entirely. No more manager objects. ! Added Minitest::Runnable. Everything minitest can run subclasses this. ! Renamed MiniTest::Unit::TestCase to Minitest::Test (subclassing Runnable). ! Added Minitest::Benchmark. ! Your benchmarks need to move to their own subclass. ! Benchmarks using the spec DSL have to have "Bench" somewhere in their describe. ! MiniTest::Unit.after_tests moved to Minitest.after_tests ! MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls. ! Removed ParallelEach#grep since it isn't used anywhere. Minor moves: + Moved Assertions module to minitest/assertions.rb + Moved Expectations module to minitest/expectations.rb + Moved Test to minitest/test.rb + Moved everything else in minitest/unit.rb to minitest.rb + minitest/unit.rb is now just a small (user-test only) compatibility layer. Additions: + Added a plugin system that can extend command-line options. + Added Minitest.extensions. + Added Minitest.reporter (only available during startup). + Added Minitest.run(args). This is the very top of any Minitest run. + Added Minitest::Reporter. Everything minitest can report goes through here. + Minitest.reporter is a composite so you can add your own. + Added Minitest::CompositeReporter. Much easier to extend with your own reporters. + Added UnexpectedError, an Assertion subclass, to wrap up errors. + Minitest::Test#run is now freakin' beautiful. 47 -> 17 loc Other: + Removed Object.infect_with_assertions (it was already dead code). + Runnables are responsible for knowing their result_code (eg "." or "F"). [git-p4: depot-paths = "//src/minitest/dev/": change = 8451]
2013-04-25 01:38:14 +00:00
describe Thingy do # class TestThingy < Minitest::Test
before do # def setup
do_some_setup # super
end # do_some_setup
# end
it "should do the first thing" do #
1.must_equal 1 # def test_first_thing
end # assert_equal 1, 1
# end
describe SubThingy do # end
before do #
do_more_setup # class TestSubThingy < TestThingy
end # def setup
# super
it "should do the second thing" do # do_more_setup
2.must_equal 2 # end
end #
end # def test_second_thing
end # assert_equal 2, 2
# end
# end
###############################################################################
# runs 2 specs # runs 3 tests
###############################################################################
# The specs generate:
class ThingySpec < Minitest::Spec
def setup
super
do_some_setup
end
def test_should_do_the_first_thing
assert_equal 1, 1
end
end
class SubThingySpec < ThingySpec
def setup
super
do_more_setup
end
# because only setup/teardown is inherited, not specs
remove_method :test_should_do_the_first_thing
def test_should_do_the_second_thing
assert_equal 2, 2
end
end