Class: TConsole::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/tconsole/test_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestResult

Returns a new instance of TestResult.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tconsole/test_result.rb', line 27

def initialize
  self.failure_count = 0
  self.error_count = 0
  self.skip_count = 0
  self.failures = []
  self.suites = {}
  self.timings = []

  self.suite_counts = {}
  self.elements = {}
end

Instance Attribute Details

#elementsObject

The element id lookup hash



22
23
24
# File 'lib/tconsole/test_result.rb', line 22

def elements
  @elements
end

#error_countObject

The number of errors that occurred in the last run



7
8
9
# File 'lib/tconsole/test_result.rb', line 7

def error_count
  @error_count
end

#failure_countObject

The number of failed tests in the last run



4
5
6
# File 'lib/tconsole/test_result.rb', line 4

def failure_count
  @failure_count
end

#failuresObject

Details about the failures in the last run



13
14
15
# File 'lib/tconsole/test_result.rb', line 13

def failures
  @failures
end

#skip_countObject

The number of skipped tests



10
11
12
# File 'lib/tconsole/test_result.rb', line 10

def skip_count
  @skip_count
end

#suite_countsObject

Test counts within various suites



25
26
27
# File 'lib/tconsole/test_result.rb', line 25

def suite_counts
  @suite_counts
end

#suitesObject

The suites that we’ve run



16
17
18
# File 'lib/tconsole/test_result.rb', line 16

def suites
  @suites
end

#timingsObject

The timings for the tests we’ve run



19
20
21
# File 'lib/tconsole/test_result.rb', line 19

def timings
  @timings
end

Instance Method Details

#add_element(suite, method) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/tconsole/test_result.rb', line 39

def add_element(suite, method)
  canonical_name = "#{suite}##{method}"

  # Just return the id if we already know about this
  if id = elements[canonical_name]
    return id
  end

  # See if we know about this suite already
  unless suite_id = elements[suite.to_s]
    suite_id = self.suite_counts.length + 1
    elements[suite.to_s] = suite_id
    suite_counts[suite.to_s] ||= 0
  end

  suite_counts[suite.to_s] += 1
  id = "#{suite_id}-#{suite_counts[suite.to_s]}"
  elements[canonical_name] = id

  id
end

#add_timing(suite, method, time) ⇒ Object



61
62
63
# File 'lib/tconsole/test_result.rb', line 61

def add_timing(suite, method, time)
  self.timings << { :name => "#{suite}##{method}", :time => time }
end