Posted on 2010-03-06 13:00
leekiang 閱讀(2901)
評論(0) 編輯 收藏 所屬分類:
ruby
1,安裝rcov0.9.9,環境為ruby1.8,6,rails2.3.5
安裝之前必須先安裝DevKit,http://github.com/oneclick/rubyinstaller/wiki/Development-Kit里有詳細的安裝步驟
主要步驟:
1)下載DevKit解壓到c:\DevKit目錄,下載地址為http://rubyinstaller.org/downloads/
2)C:\DevKit>ruby dk.rb init
3)C:\DevKit>ruby dk.rb install
4)C:\DevKit>gem install rdiscount --platform=ruby 我覺得這一步只是驗證DevKit是否安裝成功,也可以不做的。
5)最好把c:\DevKit\bin加到環境變量
2,rcov test/functional/*.rb test/unit/*.rb --output=public/rcov --rails
會生成一大堆反映測試覆蓋情況的網頁放到public/rcov目錄下,如果不寫--output,則這些網頁會放到項目下新建的coverage目錄。
3,在項目下執行rake stats可看到代碼統計,以及代碼和測試代碼的比例。
4,在netbeans6.9里開始怎么也顯示不了覆蓋率報告,后來打開一個模型類,點擊執行測試,然后就有了。
而且可以顯示每一行代碼是否被測試到,看了幾個類的覆蓋情況,感覺有的方法里的代碼明明被測了,但圖形里顯示沒有測到。
http://blogs.sun.com/tor/entry/netbeans_screenshot_of_the_week6后面的評論里有人寫了他是如何做的。
http://www.jairrillo.com/blog/2008/08/18/introduction-to-rspec-part-2-testing-the-rails-model/
http://eigenclass.org/hiki.rb?rcov#l2
http://stackoverflow.com/questions/3451346/cannot-install-rcov-from-gem