您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > cppUnit
用cppunit給每個(gè)函數(shù)添加運(yùn)行時(shí)間統(tǒng)計(jì)
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/12/18 9:59:15 ] 推薦標(biāo)簽:

必須是ruby1.8.x的版本,我用的是1.8.6,因?yàn)?.9的版本里邊沒有這個(gè)文件,文件路徑為到ruby的安裝目錄下的/test/unit/testcase.rb路徑下
def run(result)
        yield(STARTED, name)
        @_result = result
        begin
          setup
             puts "Test method:#{self}"
             num="#{self}".scan(/d{1}/)[1]
              puts "this is the #{num} testcase"
             #puts "this is the d{1,} testcase"
          time=Time.now
          __send__(@method_name)
                      difference = Time.now - time
    seconds    =  difference % 60
    #sec=seconds.to_s.scan(/d*/)[0]
    sec=seconds.round
    difference = (difference - seconds) / 60
    minutes    =  (difference % 60).round
    difference = (difference - minutes) / 60
    hours      =  (difference % 24).round

    puts "Runtime is: #{hours} hours #{minutes} minutes #{sec} seconds"
        rescue AssertionFailedError => e
          add_failure(e.message, e.backtrace)
        rescue StandardError, ScriptError
          add_error($!)
        ensure
          begin
            teardown
          rescue AssertionFailedError => e
            add_failure(e.message, e.backtrace)
          rescue StandardError, ScriptError
            add_error($!)
          end
        end
        result.add_run
        yield(FINISHED, name)
      end

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd