Module: Taf::Report
- Defined in:
- lib/taf/report.rb
Overview
report.rb - methods for outputting console.
Class Method Summary collapse
-
.check_failure_threshold(test_file_name) ⇒ Object
check if the test failure threshold has been reached for total failures or consecutive failures.
-
.current_time ⇒ Object
get the current time in the format Day - Month - Date - Time (HH:MM:SS).
- .fail_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
- .pass_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
-
.print_test_step_header(test_step_idx, test_desc) ⇒ Object
print the test Step info to the test results file.
- .skip_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
-
.test_pass_fail(pass_fail, test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
print the Pass / Fail status of a test to the test results file.
Class Method Details
.check_failure_threshold(test_file_name) ⇒ Object
check if the test failure threshold has been reached for total failures or consecutive failures. If a certain number of consecutive tests fail then throw an exception
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/taf/report.rb', line 76 def self.check_failure_threshold(test_file_name) consecutive_fail_threshold = 3 if @current_test_fail @consecutive_test_fail += 1 else @consecutive_test_fail = 0 end return if @consecutive_test_fail < consecutive_fail_threshold raise Taf::FailureThresholdExceeded, "Terminating the current test file: #{test_file_name} as the test" \ " failure threshold (#{@consecutive_test_fail}) has been reached." end |
.current_time ⇒ Object
get the current time in the format Day - Month - Date - Time (HH:MM:SS)
13 14 15 16 17 |
# File 'lib/taf/report.rb', line 13 def self.current_time require 'time' # Time.new.strftime('%a %b %d %H:%M:%S %Z') Time.new.xmlschema end |
.fail_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/taf/report.rb', line 32 def self.fail_func(test_file_name, test_step_idx, test_desc, metrics) Taf::MyLog.log.warn "Test #{test_step_idx} has FAILED ".red Taf::Screenshot.save_screenshot(test_step_idx) @current_test_fail = true metrics.stepFailures += 1 Taf::TapReport.failure( test_file_name, test_step_idx, test_desc ) end |
.pass_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/taf/report.rb', line 25 def self.pass_func(test_file_name, test_step_idx, test_desc, metrics) Taf::MyLog.log.info "Test #{test_step_idx} has Passed ".green @current_test_fail = false metrics.stepPasses += 1 Taf::TapReport.success(test_file_name, test_step_idx, test_desc) end |
.print_test_step_header(test_step_idx, test_desc) ⇒ Object
print the test Step info to the test results file
20 21 22 23 |
# File 'lib/taf/report.rb', line 20 def self.print_test_step_header(test_step_idx, test_desc) @start_time = current_time Taf::MyLog.log.info "Test step: #{test_step_idx} : #{test_desc}" end |
.skip_func(test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/taf/report.rb', line 42 def self.skip_func(test_file_name, test_step_idx, test_desc, metrics) Taf::MyLog.log.info "Test #{test_step_idx} no checks performed ".blue @current_test_fail = false metrics.stepSkipped += 1 Taf::TapReport.skip( test_file_name, test_step_idx, test_desc ) end |
.test_pass_fail(pass_fail, test_file_name, test_step_idx, test_desc, metrics) ⇒ Object
print the Pass / Fail status of a test to the test results file
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/taf/report.rb', line 52 def self.test_pass_fail( pass_fail, test_file_name, test_step_idx, test_desc, metrics ) if pass_fail pass_func(test_file_name, test_step_idx, test_desc, metrics) elsif pass_fail == false fail_func(test_file_name, test_step_idx, test_desc, metrics) else skip_func(test_file_name, test_step_idx, test_desc, metrics) end end_time = current_time duration = TimeDifference.between(end_time, @start_time).humanize || 0 Taf::MyLog.log.info "Test step duration: #{duration} \n" end |