Class: Taf::TapReport
- Inherits:
-
Object
- Object
- Taf::TapReport
- Includes:
- Singleton
- Defined in:
- lib/taf/tap_report.rb
Overview
tap_report.rb - methods for outputting to a tap report file.
Instance Attribute Summary collapse
-
#tests ⇒ Object
Returns the value of attribute tests.
Class Method Summary collapse
- .add_step(filename, step) ⇒ Object
- .failure(filename, index, description) ⇒ Object
- .output ⇒ Object
- .skip(filename, index, description) ⇒ Object
- .success(filename, index, description) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ TapReport
constructor
A new instance of TapReport.
Constructor Details
#initialize ⇒ TapReport
Returns a new instance of TapReport.
79 80 81 |
# File 'lib/taf/tap_report.rb', line 79 def initialize @tests = {} end |
Instance Attribute Details
#tests ⇒ Object
Returns the value of attribute tests.
83 84 85 |
# File 'lib/taf/tap_report.rb', line 83 def tests @tests end |
Class Method Details
.add_step(filename, step) ⇒ Object
33 34 35 36 |
# File 'lib/taf/tap_report.rb', line 33 def self.add_step(filename, step) instance.tests[filename] ||= [] instance.tests[filename] << step end |
.failure(filename, index, description) ⇒ Object
21 22 23 24 25 |
# File 'lib/taf/tap_report.rb', line 21 def self.failure(filename, index, description) step = Taf::TestSteps::FailureStep.new(index: index, description: description) add_step filename, step end |
.output ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/taf/tap_report.rb', line 38 def self.output project_id = Taf::JSONParser.project_id.delete(' ') ts_dir = File.join('Results', project_id) file = File.open("#{ts_dir}/report_#{SecureRandom.uuid}.tap", 'w') total_steps = 0 successes = 0 failures = 0 skips = 0 instance.tests.each do |filename, steps| file.write("# #{filename}\n") steps.each do |step| total_steps += 1 if step.is_a?(Taf::TestSteps::SkipStep) outstr = "ok #{total_steps} #{step.description} # SKIP"\ " - Step #{step.index} Test File: #{filename}" skips += 1 else if step.is_a?(Taf::TestSteps::SuccessStep) outstr = 'ok ' successes += 1 elsif step.is_a?(Taf::TestSteps::FailureStep) outstr = 'not ok ' failures += 1 else outstr = '# test error' end outstr += "#{total_steps} #{step.description} - Step #{step.index}"\ " Test File: #{filename}" end file.write(outstr + "\n") end end file.write("1..#{total_steps}\n") file.write("# tests #{total_steps}\n") file.write("# pass #{successes}\n") file.write("# fail #{failures}\n") file.write("# skip #{skips}\n") file.close end |
.skip(filename, index, description) ⇒ Object
27 28 29 30 31 |
# File 'lib/taf/tap_report.rb', line 27 def self.skip(filename, index, description) step = Taf::TestSteps::SkipStep.new(index: index, description: description) add_step filename, step end |
.success(filename, index, description) ⇒ Object
15 16 17 18 19 |
# File 'lib/taf/tap_report.rb', line 15 def self.success(filename, index, description) step = Taf::TestSteps::SuccessStep.new(index: index, description: description) add_step filename, step end |