Class: QAT::Formatter::Xray
- Inherits:
-
Object
- Object
- QAT::Formatter::Xray
- Includes:
- Cucumber::Formatter::Io, Helper, 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
- #attach(src, mime_type) ⇒ Object
-
#initialize(config) ⇒ Xray
constructor
A new instance of Xray.
- #on_test_case_finished(event) ⇒ Object private
- #on_test_case_started(event) ⇒ Object private
- #on_test_run_finished(_event) ⇒ Object
- #tag_name(tag_name) ⇒ Object private
Constructor Details
#initialize(config) ⇒ Xray
Returns a new instance of Xray.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qat/formatter/xray.rb', line 22 def initialize(config) @config = config @io = ensure_io(config.out_stream, config.error_stream) @ast_lookup = ::Cucumber::Formatter::AstLookup.new(config) @feature_hashes = [] config.on_event :test_case_started, &method(:on_test_case_started) config.on_event :test_case_finished, &method(:on_test_case_finished) config.on_event :test_run_finished, &method(:on_test_run_finished) @tests = [] end |
Instance Method Details
#attach(src, mime_type) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/qat/formatter/xray.rb', line 91 def attach(src, mime_type) 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) else "#{src}.#{ext}" end @evidences << { data: data, filename: file_name, contentType: mime_type } end |
#on_test_case_finished(event) ⇒ 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/qat/formatter/xray.rb', line 58 def on_test_case_finished event return if @config.dry_run? _test_case, result = *event.attributes # When jira type is cloud the test result string must be different (accordingly with xray api) test_status = if result.passed? jira_type == 'cloud' ? 'PASSED' : 'PASS' elsif result.failed? jira_type == 'cloud' ? 'FAILED' : 'FAIL' else 'NO RUN' end @end_time = Time.now comment = result.respond_to?(:exception) ? build_exception(result.exception) : '' log.warn 'Jira ID is not defined!' unless @test_jira_id if @examples_values save_current_scenario_outline(test_status, comment) else save_current_scenario(test_status, comment) end end |
#on_test_case_started(event) ⇒ 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/qat/formatter/xray.rb', line 39 def on_test_case_started(event) return if @config.dry_run? @row_number = nil test_case = event.test_case build(test_case, @ast_lookup) @current_scenario = @scenario @exception = nil @start_time = Time.now @evidences = [] @file_counter = 0 @current_scenario[:tags].each do |tag| tag_name tag end end |
#on_test_run_finished(_event) ⇒ Object
84 85 86 87 |
# File 'lib/qat/formatter/xray.rb', line 84 def on_test_run_finished _event return if @config.dry_run? publish_result 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.
34 35 36 |
# File 'lib/qat/formatter/xray.rb', line 34 def tag_name(tag_name) @test_jira_id = tag_name.to_s.split('_')[1] if tag_name.match(test_tag_regex) end |