• 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

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 Png genki on Sat 3 Feb 2007 at 05:47

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry107
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ