Class: Tunit::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/tunit/reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = $stdout, options = {}) ⇒ Reporter

Returns a new instance of Reporter.



3
4
5
6
7
8
9
# File 'lib/tunit/reporter.rb', line 3

def initialize io = $stdout, options = {}
  self.io         = io
  self.options    = options
  self.assertions = 0
  self.count      = 0
  self.results    = []
end

Instance Attribute Details

#assertionsObject

Returns the value of attribute assertions.



10
11
12
# File 'lib/tunit/reporter.rb', line 10

def assertions
  @assertions
end

#countObject

Returns the value of attribute count.



10
11
12
# File 'lib/tunit/reporter.rb', line 10

def count
  @count
end

#errorsObject

Returns the value of attribute errors.



12
13
14
# File 'lib/tunit/reporter.rb', line 12

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



12
13
14
# File 'lib/tunit/reporter.rb', line 12

def failures
  @failures
end

#ioObject

Returns the value of attribute io.



10
11
12
# File 'lib/tunit/reporter.rb', line 10

def io
  @io
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/tunit/reporter.rb', line 10

def options
  @options
end

#resultsObject

Returns the value of attribute results.



10
11
12
# File 'lib/tunit/reporter.rb', line 10

def results
  @results
end

#skipsObject

Returns the value of attribute skips.



12
13
14
# File 'lib/tunit/reporter.rb', line 12

def skips
  @skips
end

#start_timeObject

Returns the value of attribute start_time.



11
12
13
# File 'lib/tunit/reporter.rb', line 11

def start_time
  @start_time
end

#total_timeObject

Returns the value of attribute total_time.



11
12
13
# File 'lib/tunit/reporter.rb', line 11

def total_time
  @total_time
end

Instance Method Details

#passed?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/tunit/reporter.rb', line 25

def passed?
  results.all?(&:skipped?)
end

#record(result) ⇒ Object



18
19
20
21
22
23
# File 'lib/tunit/reporter.rb', line 18

def record result
  self.count += 1
  self.assertions += result.assertions

  self.results << result if !result.passed? || result.skipped?
end

#reportObject



29
30
31
32
33
34
35
36
37
# File 'lib/tunit/reporter.rb', line 29

def report
  total           = results.group_by {|r| r.failure.class }
  total.default   = []

  self.total_time   = Time.now - start_time
  self.failures     = total[Assertion].size
  self.failures    += total[Empty].size
  self.skips        = total[Skip].size
end

#startObject



14
15
16
# File 'lib/tunit/reporter.rb', line 14

def start
  self.start_time = Time.now
end