3rd Sat
テストをテストするメタテスト
This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/162
RailsのIntegrationTestの仕組みを使って、Code To Test Ratio(コード量に対するテストコードの割合)が一定以上に保たれているかどうかを検証するテストを書いてみました。
require "#{File.dirname(__FILE__) }/../test_helper"
class TestingRuleTest < ActionController::IntegrationTest
def setup
@stats = `rake stats`
end
def test_code_to_test_ratio
cttr = @stats.match(%r{Code to Test Ratio: 1:([\d\.]+)})[1].to_f
assert cttr >= 0.8, "Need more tests."
end
end
多人数で開発をしてるとなかなか面白いですよ。一人の場合でも自分への戒めに使えるかな。
[English]
This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/162
posted by
genki on Sat 3 Feb 2007 at 05:47 with 0 comments