1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
$:.unshift(File.dirname(__FILE__) + "/../../lib/")
require 'benchmark'
#
# Model
class Room
attr_reader :name
def initialize(name)
@name = name
end
end
#
# Test::Unit
require 'test/unit'
Test::Unit.run = true
require 'test/unit/ui/console/testrunner'
class RoomTest < Test::Unit::TestCase
def setup
@room = Room.new("bed")
end
def test_room_should_be_named_bed
assert_equal "bed", @room.name
end
end
#
# Shoulda
require 'rubygems'
require 'shoulda'
class ShouldaRoomTest < Test::Unit::TestCase
def setup
@room = Room.new("bed")
end
should("be named 'bed'") { assert_equal "bed", @room.name }
end
#
# Riot
require 'riot'
context "a room" do
setup { Room.new("bed") }
asserts("name") { topic.name }.equals("bed")
end # a room
#
# Benchmarking
n = 100 * 100
Benchmark.bmbm do |x|
x.report("Riot") do
Riot.silently!
Riot.alone!
n.times { Riot.run }
end
x.report("Test::Unit") do
n.times { Test::Unit::UI::Console::TestRunner.new(RoomTest, Test::Unit::UI::SILENT) }
end
x.report("Shoulda") do
n.times { Test::Unit::UI::Console::TestRunner.new(ShouldaRoomTest, Test::Unit::UI::SILENT) }
end
end
|