??????????????????????????? unit test ???????????


require 'test/unit'
require_relative '../lib/ex47'

class MyUnitTests  north?? :south => south})
    assert_equal(center.go(:north)?? north)
    assert_equal(center.go(:south)?? south)
  end

  def test_map()
    start = Room.new("Start"?? "You can go west and down a hole.")
    west = Room.new("Trees"?? "There are trees here?? you can go east.")
    down = Room.new("Dungeon"?? "It's dark down here?? you can go up.")

    start.add_paths({:west => west?? :down => down})
    west.add_paths({:east => start})
    down.add_paths({:up => start})

    assert_equal(start.go(:west)?? west)
    assert_equal(start.go(:west).go(:east)?? start)
    assert_equal(start.go(:down).go(:up)?? start)
  end

end
 
?????????? require ??????lib/ex47.rb ?????? Room???????????????????????????????????????????е??? test_ ?????????????????????ν???Test Case????????Test Case???涼???С?δ??????????????????Щ??????????????????????????????????????????????????書???????????·????????????????????

?????????????????? assert_equal????????????????????????????Room ???????·???????????????????????????????????Ruby ?? Test::Unit ??齫??????????????????????????????????????????????????

???????????

??????д?????????????????????????Щ??????????????????

????1???????????? tests/???£??????????test_NAME.rb??????????????????????????????????????

????2?????????????д????????

????3??Test Cast ?????????????????????????????????????Test Cast????е????

????4????Test Cast??Щ????????????????????????????????????????????Щ???????????????????????????′?????????????????????????л???????????????????????????????ú????????

????5????????????????????????????????????????????????????????????????????

????????????????


$ ruby test_ex47.rb
Loaded suite test_ex47
Started
...
Finished in 0.000353 seconds.

3 tests?? 7 assertions?? 0 failures?? 0 errors?? 0 skips

Test run options: --seed 63537
 


???????????????????????н??????????????????????в??????????????????????

??????????

????1????????Test::Unit?????????????????????????????????

????2???????? Rspec??????????????????????

????3????????????? Room?????????????????????????д??????????д??????????????д??????