On Sat, 28 Feb 2004 22:58:56 +0900, David Garamond wrote:
[snip]
> We'd like to put several metadata into the test collection to get a 
> better picture of the state of the tests. At least we'd like to get the 
> following information:
> 
> 1. total number of test methods, cases, and suites.

I think you can extract info from Test::Unit.

 
> 2. LOC per each test case and test suite, and total LOC dedicated to 
> testing (this will eventually be compared to total LOC of code, LOC of 
> comments, LOC of documentation, etc); aside from LOC, number of 
> chars/bytes will also be used as another unit of measure.

LOC per testcase is difficult.. some parsing of Ruby code will be
necessary.. maybe ripper can be useful for extracting this info?

 
> 3. number (and, as % of LOC) of tests that are interactive (i.e. GUI tests).

coverage.rb, may help identify which pieces of code that hasn't been
reached during execution.

 
> 4. time-cost of each test case and total (i.e. we assign a number/weight 
> to each test case to get a feel of how long tests will run).

extend the TestCase class with a #time_score method, so that you can
collect info about how much each test will require before invoking the
tests. Something like

# FILE='test_hours.rb'
require 'common'
class TestScanner < Common::TestCase 
  def test_longevity
    sleep(100000)  # 100 seconds
  end
  def test_ping
    # ping server, get feedback..  50 seconds
  end
  time_score(:test_longevity, 100)
  time_score(:test_ping, 50)
end
TestScanner.run if $0 == __FILE__


# FILE='common.rb'
def TestCase.time_score(symbol, seconds)
  @time[symbol] = seconds
end


Then the #run method would be able to measure how much time there is
required by each testcase.
 
--
Simon Strandgaard