Class: MonkeyTest::TestClass

Inherits:
Object
  • Object
show all
Defined in:
lib/monkeytest/testclass.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ TestClass

Returns a new instance of TestClass.



10
11
12
13
# File 'lib/monkeytest/testclass.rb', line 10

def initialize(name=nil)
  @name = name
  @tests = Hash.new
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/monkeytest/testclass.rb', line 7

def name
  @name
end

#testsObject (readonly)

Returns the value of attribute tests.



8
9
10
# File 'lib/monkeytest/testclass.rb', line 8

def tests
  @tests
end

Instance Method Details

#add_test(test) ⇒ Object



15
16
17
18
# File 'lib/monkeytest/testclass.rb', line 15

def add_test(test)
  return unless test.kind_of? MonkeyTest::Test and !test.name.nil? and @tests[test.name].nil?
  @tests[test.name] = test
end

#each_testObject

The same as: testClass.tests.each



30
31
32
33
34
# File 'lib/monkeytest/testclass.rb', line 30

def each_test
  @tests.each_value do |t|
    yield t
  end
end

#num_assertionsObject



40
41
42
43
44
45
46
# File 'lib/monkeytest/testclass.rb', line 40

def num_assertions
  assertions = 0
  @tests.each_value do |t|
    assertions += t.assertions
  end
  return assertions
end

#num_testsObject



36
37
38
# File 'lib/monkeytest/testclass.rb', line 36

def num_tests
  @tests.size
end

#worstObject



20
21
22
23
24
25
26
27
# File 'lib/monkeytest/testclass.rb', line 20

def worst
  worst = "PASS"
  @tests.each_value do |t|
    worst = "FAIL" if t.status == "FAIL" and worst != "ERROR"
    worst = "ERROR" if t.status == "ERROR"
  end
  return worst
end