Class: Turn::TestSuite

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/turn/components/suite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ TestSuite

Returns a new instance of TestSuite.


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/turn/components/suite.rb', line 17

def initialize(name=nil)
  @name  = name
  @cases = []
  @size  = nil
  @seed  = nil

  #@count_tests      = nil
  #@count_assertions = nil
  #@count_failures   = nil
  #@count_errors     = nil
  #@count_passes     = nil
end

Instance Attribute Details

#casesObject

Returns the value of attribute cases


9
10
11
# File 'lib/turn/components/suite.rb', line 9

def cases
  @cases
end

#count_assertionsObject


43
44
45
46
47
# File 'lib/turn/components/suite.rb', line 43

def count_assertions
  #@count_assertions ||= (
    sum = 0; each{ |c| sum += c.count_assertions }; sum
  #)
end

#nameObject

Returns the value of attribute name


8
9
10
# File 'lib/turn/components/suite.rb', line 8

def name
  @name
end

#seedObject

Returns the value of attribute seed


10
11
12
# File 'lib/turn/components/suite.rb', line 10

def seed
  @seed
end

Instance Method Details

#count_errorsObject


55
56
57
58
59
# File 'lib/turn/components/suite.rb', line 55

def count_errors
  #@count_errors ||= (
    sum = 0; each{ |c| sum += c.count_errors }; sum
  #)
end

#count_failuresObject


49
50
51
52
53
# File 'lib/turn/components/suite.rb', line 49

def count_failures
  #@count_failures ||= (
    sum = 0; each{ |c| sum += c.count_failures }; sum
  #)
end

#count_passesObject


61
62
63
64
65
# File 'lib/turn/components/suite.rb', line 61

def count_passes
  #@count_passes ||= (
    sum = 0; each{ |c| sum += c.count_passes }; sum
  #)
end

#count_skipsObject


67
68
69
# File 'lib/turn/components/suite.rb', line 67

def count_skips
  sum = 0; each{ |c| sum += c.count_skips }; sum
end

#count_testsObject


37
38
39
40
41
# File 'lib/turn/components/suite.rb', line 37

def count_tests
  #@count_tests ||= (
    sum = 0; each{ |c| sum += c.count_tests }; sum
  #)
end

#countsObject

Convenience methods –this is what is typcially wanted.


72
73
74
# File 'lib/turn/components/suite.rb', line 72

def counts
  return count_tests, count_assertions, count_failures, count_errors ,count_skips
end

#each(&block) ⇒ Object


76
77
78
# File 'lib/turn/components/suite.rb', line 76

def each(&block)
  @cases.each(&block)
end

#new_case(name, *files) ⇒ Object


31
32
33
34
35
# File 'lib/turn/components/suite.rb', line 31

def new_case(name, *files)
  c = TestCase.new(name, *files)
  @cases << c
  c
end

#passed?Boolean

Returns:

  • (Boolean)

89
90
91
# File 'lib/turn/components/suite.rb', line 89

def passed?
  (count_failures == 0 && count_errors == 0)
end

#sizeObject


80
81
82
# File 'lib/turn/components/suite.rb', line 80

def size
  @size ||= @cases.size
end

#size=(number) ⇒ Object

Why the size would ever have to overridden… well who can say.


85
86
87
# File 'lib/turn/components/suite.rb', line 85

def size=(number)
  @size = number.to_i
end