Class: QAT::Formatter::Xray
- Inherits:
-
Object
- Object
- QAT::Formatter::Xray
- Includes:
- Cucumber::Formatter::Io, Logger
- Defined in:
- lib/qat/formatter/xray.rb,
lib/qat/formatter/xray/test_ids.rb
Overview
Namespace for Xray formatter
Defined Under Namespace
Classes: TestIds
Instance Method Summary collapse
- #after_features(*_) ⇒ Object private
- #after_test_case(_, status) ⇒ Object private
- #before_test_case(test_case) ⇒ Object private
- #embed(src, mime_type, label) ⇒ Object
-
#initialize(runtime, path_or_io, options) ⇒ Xray
constructor
private
A new instance of Xray.
- #tag_name(tag_name) ⇒ Object private
Constructor Details
#initialize(runtime, path_or_io, options) ⇒ Xray
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Xray.
21 22 23 24 25 |
# File 'lib/qat/formatter/xray.rb', line 21 def initialize(runtime, path_or_io, ) @io = ensure_io(path_or_io) @options = @tests = [] end |
Instance Method Details
#after_features(*_) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/qat/formatter/xray.rb', line 68 def after_features(*_) publish_result end |
#after_test_case(_, status) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/qat/formatter/xray.rb', line 44 def after_test_case(_, status) # When jira type is cloud the test result string must be different (accordingly with xray api) test_status = if status.is_a? ::Cucumber::Core::Test::Result::Passed jira_type == 'cloud' ? 'PASSED' : 'PASS' elsif status.is_a? ::Cucumber::Core::Test::Result::Failed jira_type == 'cloud' ? 'FAILED' : 'FAIL' else 'NO RUN' end @end_time = Time.now comment = status.respond_to?(:exception) ? build_exception(status.exception) : '' log.warn 'Jira ID is not defined!' unless @test_jira_id if @current_scenario.is_a? ::Cucumber::Core::Ast::ScenarioOutline save_current_scenario_outline(test_status, comment) else save_current_scenario(test_status, comment) end end |
#before_test_case(test_case) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 41 |
# File 'lib/qat/formatter/xray.rb', line 33 def before_test_case(test_case) @current_scenario = test_case.source[1] @exception = nil @start_time = Time.now @evidences = [] @file_counter = 0 end |
#embed(src, mime_type, label) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/qat/formatter/xray.rb', line 72 def (src, mime_type, label) data = if File.file?(src) File.open(src) do |file| Base64.strict_encode64(file.read) end elsif src =~ /^data:image\/(png|gif|jpg|jpeg);base64,/ src else Base64.strict_encode64(src) end ext = mime_type.split('/').last file_name = if File.file?(src) File.basename(src) elsif label.to_s.empty? "file_#{@file_counter += 1}.#{ext}" else "#{label}.#{ext}" end @evidences << { data: data, filename: file_name, contentType: mime_type } end |
#tag_name(tag_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/qat/formatter/xray.rb', line 28 def tag_name(tag_name) @test_jira_id = tag_name.to_s.split('_')[1] if tag_name.match(test_tag_regex) end |