write ahead log

ロールフォワード用

Test::Unitでテストを定義順に実行する

Test::Unitはデフォルトではテストを名前順に実行する.

require 'test/unit'

class TestSample < Test::Unit::TestCase
  def test_B
    puts "B"
  end

  def test_A
    puts "A"
  end
end
$ ruby sample.rb
Loaded suite sample
Started
A
.B
.

Finished in 0.0011721 seconds.
-------------------------------------------------------------------------------------
2 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------------
1706.34 tests/s, 0.00 assertions/s

これを定義順にしてやりたいときにはtest_order = :definedという指定が出来るらしい.

require 'test/unit'

class TestSample < Test::Unit::TestCase

  self.test_order = :defined

  def test_B
    puts "B"
  end

  def test_A
    puts "A"
  end
end
$ ruby sample.rb
Loaded suite sample
Started
B
.A
.

Finished in 0.000768 seconds.
--------------------------------------------------------------------------------------
2 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
--------------------------------------------------------------------------------------
2604.17 tests/s, 0.00 assertions/s

うーん, 設計がダサい証拠な気もするけど, 便利だ.