Class: Turn::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/turn/components/case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *files) ⇒ TestCase

Returns a new instance of TestCase.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/turn/components/case.rb', line 31

def initialize(name, *files)
  @name  = name
  @files = (files.empty? ? [name] : files)
  @tests = []

  @message = nil
  @count_assertions = 0

  #@count_tests      = 0
  #@count_failures   = 0
  #@count_errors     = 0

  #@command = command
end

Instance Attribute Details

#count_assertionsObject

This can;t be calculated, so it must be assigned by the runner.



22
23
24
# File 'lib/turn/components/case.rb', line 22

def count_assertions
  @count_assertions
end

#filesObject

Some runners marshal tests per file.



13
14
15
# File 'lib/turn/components/case.rb', line 13

def files
  @files
end

#messageObject

Holds dump of test output (optional depending on runner).



25
26
27
# File 'lib/turn/components/case.rb', line 25

def message
  @message
end

#nameObject

Name of test case.



7
8
9
# File 'lib/turn/components/case.rb', line 7

def name
  @name
end

#testsObject

Test methods.



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

def tests
  @tests
end

Instance Method Details

#count_errorsObject



78
79
80
# File 'lib/turn/components/case.rb', line 78

def count_errors
  sum = 0; tests.each{ |t| sum += 1 if t.error? }; sum
end

#count_failuresObject



74
75
76
# File 'lib/turn/components/case.rb', line 74

def count_failures
  sum = 0; tests.each{ |t| sum += 1 if t.fail? }; sum
end

#count_passesObject



82
83
84
# File 'lib/turn/components/case.rb', line 82

def count_passes
  sum = 0; tests.each{ |t| sum += 1 if t.pass? }; sum
end

#count_testsObject



70
71
72
# File 'lib/turn/components/case.rb', line 70

def count_tests
  tests.size
end

#countsObject



87
88
89
# File 'lib/turn/components/case.rb', line 87

def counts
  return count_tests, count_assertions, count_failures, count_errors
end

#error?Boolean

Were there any errors?

Returns:

  • (Boolean)


56
57
58
# File 'lib/turn/components/case.rb', line 56

def error?
  count_errors != 0
end

#fail?Boolean

Were there any failures?

Returns:

  • (Boolean)


61
62
63
# File 'lib/turn/components/case.rb', line 61

def fail?
  count_failures != 0
end

#new_test(name) ⇒ Object



46
47
48
49
50
# File 'lib/turn/components/case.rb', line 46

def new_test(name)
  c = TestMethod.new(name)
  @tests << c
  c
end

#pass?Boolean

Did all tests/assertion pass?

Returns:

  • (Boolean)


66
67
68
# File 'lib/turn/components/case.rb', line 66

def pass?
  not(fail? or error?)
end