Sha256: d97c23f5e74e01538a96e84a00fd3963a5fdd3dafc032e80e4c31c561b9698c4

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

$:.concat ['./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'
Riot.silently!

#
# Benchmarking

n = 100 * 100

Benchmark.bmbm do |x|
  x.report("Riot") do
    n.times do
      context "a room" do
        setup { @room = Room.new("bed") }

        asserts("name") { @room.name }.equals("bed")
      end # a room
    end
  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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
riot-0.9.12 test/benchmark/simple_context_and_assertions.rb
riot-0.9.11 test/benchmark/simple_context_and_assertions.rb
riot-0.9.10 test/benchmark/simple_context_and_assertions.rb
riot-0.9.9 test/benchmark/simple_context_and_assertions.rb
riot-0.9.8 test/benchmark/simple_context_and_assertions.rb
riot-0.9.7 test/benchmark/simple_context_and_assertions.rb
riot-0.9.6 test/benchmark/simple_context_and_assertions.rb
riot-0.9.5 test/benchmark/simple_context_and_assertions.rb
riot-0.9.4 test/benchmark/simple_context_and_assertions.rb