Module: AutoTest::Error

Included in:
AutoTest
Defined in:
lib/error.rb

Overview

This module deals with all functions concerning errors

Class Method Summary collapse

Class Method Details

.get_errorObject

get the error count



42
43
44
# File 'lib/error.rb', line 42

def get_error
  @error[0]
end

.get_error_messagesObject

get error message



47
48
49
# File 'lib/error.rb', line 47

def get_error_messages
  @error[1..@error.size-1]
end

.inc_error(value) ⇒ Object

increment the errorcount in the first field of the array, add error messages



11
12
13
14
15
16
17
18
19
# File 'lib/error.rb', line 11

def inc_error(value)
  if !get_error_messages.include? value then
    @error[0] = @error[0] + 1
    @error << value
    if Test.stop_at_first_error? then
      Test.stop!
    end
  end
end

.init_errorObject

init error count with 0



52
53
54
# File 'lib/error.rb', line 52

def init_error
  @error = [0]
end

print the error on the console just the message of the exception, no backtrace



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/error.rb', line 23

def print_errors
  if get_error > 0 then
    if get_error == 1 then
      puts "There was 1 Error in this test:"
      get_error_messages.each do |m|
        puts m
      end
    else
      puts "There were " + get_error.to_s + " Errors in this test:"
      get_error_messages.each do |m|
        puts m
      end      
    end
  else
    puts "There were no errors in this test"
  end
end