Class: DevCreek::TestResult

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

Constant Summary collapse

OK =
"OK"
FAILURE =
"FAILURE"
ERROR =
"ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_name, test_class, status = OK, start = Time.now) ⇒ TestResult

Returns a new instance of TestResult.



15
16
17
# File 'lib/devcreek_testresult.rb', line 15

def initialize(test_name, test_class, status=OK, start=Time.now)
  @test_name, @test_class, @status, @start = test_name, test_class, status, start
end

Instance Attribute Details

#finishObject (readonly)

Returns the value of attribute finish.



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

def finish
  @finish
end

#startObject (readonly)

Returns the value of attribute start.



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

def start
  @start
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#test_classObject (readonly)

Returns the value of attribute test_class.



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

def test_class
  @test_class
end

#test_nameObject (readonly)

Returns the value of attribute test_name.



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

def test_name
  @test_name
end

Instance Method Details

#elapsed_timeObject



24
25
26
# File 'lib/devcreek_testresult.rb', line 24

def elapsed_time
  return finish - start unless finish.nil? or start.nil?
end

#has_a_failureObject



28
29
30
# File 'lib/devcreek_testresult.rb', line 28

def has_a_failure
  @status = FAILURE    
end

#has_an_errorObject



32
33
34
# File 'lib/devcreek_testresult.rb', line 32

def has_an_error
  @status = ERROR    
end

#has_finishedObject

Raises:

  • (ArgumentError)


19
20
21
22
# File 'lib/devcreek_testresult.rb', line 19

def has_finished
  raise ArgumentError, "The finish time cannot be set twice" unless @finish.nil?
  @finish = Time.now
end