Class: Moto::Reporting::RunStatus
- Inherits:
-
Object
- Object
- Moto::Reporting::RunStatus
- Defined in:
- lib/reporting/run_status.rb
Overview
Value object holding information about whole ‘run’ of tests.
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Run’s duration.
-
#tests_all ⇒ Object
readonly
Array of all statuses [Moto::Test:Status] from current run.
-
#tests_error ⇒ Object
readonly
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::ERROR].
-
#tests_failed ⇒ Object
readonly
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::FAILURE].
-
#tests_passed ⇒ Object
readonly
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::PASSED].
-
#tests_skipped ⇒ Object
readonly
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::SKIPPED].
-
#time_end ⇒ Object
readonly
Time of run’s end.
-
#time_start ⇒ Object
readonly
Time of run’s start.
Instance Method Summary collapse
-
#add_test_status(test_status) ⇒ Object
Adds single test’s status to the collection which describes whole run.
- #finalize_run ⇒ Object
-
#initialize ⇒ RunStatus
constructor
A new instance of RunStatus.
- #initialize_run ⇒ Object
-
#result ⇒ String
Summarized result of whole run.
-
#to_s ⇒ String
Overwritten definition of to string.
Constructor Details
#initialize ⇒ RunStatus
Returns a new instance of RunStatus.
31 32 33 34 35 36 37 |
# File 'lib/reporting/run_status.rb', line 31 def initialize @tests_all = [] @tests_passed = [] @tests_skipped = [] @tests_failed = [] @tests_error = [] end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Run’s duration
29 30 31 |
# File 'lib/reporting/run_status.rb', line 29 def duration @duration end |
#tests_all ⇒ Object (readonly)
Array of all statuses [Moto::Test:Status] from current run
8 9 10 |
# File 'lib/reporting/run_status.rb', line 8 def tests_all @tests_all end |
#tests_error ⇒ Object (readonly)
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::ERROR]
20 21 22 |
# File 'lib/reporting/run_status.rb', line 20 def tests_error @tests_error end |
#tests_failed ⇒ Object (readonly)
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::FAILURE]
17 18 19 |
# File 'lib/reporting/run_status.rb', line 17 def tests_failed @tests_failed end |
#tests_passed ⇒ Object (readonly)
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::PASSED]
11 12 13 |
# File 'lib/reporting/run_status.rb', line 11 def tests_passed @tests_passed end |
#tests_skipped ⇒ Object (readonly)
Array of [Moto::Test:Status] with @results.last.code == [Moto::Test::Result::SKIPPED]
14 15 16 |
# File 'lib/reporting/run_status.rb', line 14 def tests_skipped @tests_skipped end |
#time_end ⇒ Object (readonly)
Time of run’s end
26 27 28 |
# File 'lib/reporting/run_status.rb', line 26 def time_end @time_end end |
#time_start ⇒ Object (readonly)
Time of run’s start
23 24 25 |
# File 'lib/reporting/run_status.rb', line 23 def time_start @time_start end |
Instance Method Details
#add_test_status(test_status) ⇒ Object
Adds single test’s status to the collection which describes whole run
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/reporting/run_status.rb', line 65 def add_test_status(test_status) # Separate collections are kept and data is doubled in order to avoid # calling Array.collect in getter for each type of results case test_status.results.last.code when Moto::Test::Result::PASSED @tests_passed << test_status when Moto::Test::Result::SKIPPED @tests_skipped << test_status when Moto::Test::Result::FAILURE @tests_failed << test_status when Moto::Test::Result::ERROR @tests_error << test_status else raise 'Incorrect value of field: "code" in [Moto::Test::Status]' end @tests_all << test_status end |
#finalize_run ⇒ Object
43 44 45 46 |
# File 'lib/reporting/run_status.rb', line 43 def finalize_run @time_end = Time.now.to_f @duration = @time_end - @time_start end |
#initialize_run ⇒ Object
39 40 41 |
# File 'lib/reporting/run_status.rb', line 39 def initialize_run @time_start = Time.now.to_f end |
#result ⇒ String
Summarized result of whole run
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/reporting/run_status.rb', line 50 def result if @tests_error.length > 0 return Moto::Test::Result::ERROR elsif @tests_failed.length > 0 return Moto::Test::Result::FAILURE elsif tests_all.length == @tests_skipped.length return Moto::Test::Result::SKIPPED end Moto::Test::Result::PASSED end |
#to_s ⇒ String
Overwritten definition of to string.
88 89 90 91 92 93 94 95 |
# File 'lib/reporting/run_status.rb', line 88 def to_s case result when Moto::Test::Result::PASSED then return 'PASSED' when Moto::Test::Result::FAILURE then return 'FAILED' when Moto::Test::Result::ERROR then return 'ERROR' when Moto::Test::Result::SKIPPED then return 'SKIPPED' end end |