Class: MonkeyTest::TestClass
- Inherits:
-
Object
- Object
- MonkeyTest::TestClass
- Defined in:
- lib/monkeytest/testclass.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
- #add_test(test) ⇒ Object
-
#each_test ⇒ Object
The same as: testClass.tests.each.
-
#initialize(name = nil) ⇒ TestClass
constructor
A new instance of TestClass.
- #num_assertions ⇒ Object
- #num_tests ⇒ Object
- #worst ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/monkeytest/testclass.rb', line 7 def name @name end |
#tests ⇒ Object (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_test ⇒ Object
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_assertions ⇒ Object
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_tests ⇒ Object
36 37 38 |
# File 'lib/monkeytest/testclass.rb', line 36 def num_tests @tests.size end |
#worst ⇒ Object
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 |