Module: Jericho
- Defined in:
- lib/jericho.rb,
lib/jericho/version.rb
Constant Summary collapse
- VERSION =
"0.2.8"
Class Method Summary collapse
- .comparison_reporter(list_of_scenarios_reports1, list_of_scenarios_reports2) ⇒ Object
- .get_jenkins_job_name ⇒ Object
- .purify ⇒ Object
- .repent ⇒ Object
- .reporter(parsed_report) ⇒ Object
Class Method Details
.comparison_reporter(list_of_scenarios_reports1, list_of_scenarios_reports2) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jericho.rb', line 25 def self.comparison_reporter(list_of_scenarios_reports1, list_of_scenarios_reports2) failed_tests = list_of_scenarios_reports2.select { |k, v| v == 'Failed' }.map do |k, v| { test_name: k === '' ? k = 'Background' : k, actual_status: v, previous_status: list_of_scenarios_reports1[k] }.reject { |_k, v| v.nil? } end { passed: list_of_scenarios_reports2.size - failed_tests.size, failed: failed_tests.size, failed_tests: failed_tests } end |
.get_jenkins_job_name ⇒ Object
18 19 20 21 22 23 |
# File 'lib/jericho.rb', line 18 def self.get_jenkins_job_name name = '' file = File.open('logfile.txt') file.map {|line| name += line} return name.chomp end |
.purify ⇒ Object
41 42 43 44 45 46 |
# File 'lib/jericho.rb', line 41 def self.purify arr = Dir['*.json'].sort! arr.length <= 1 ? parsed_report1 = {} : parsed_report1 = JSON.parse(File.read(arr[-2])) parsed_report2 = JSON.parse(File.read(arr.last)) purify = comparison_reporter(reporter(parsed_report1), reporter(parsed_report2)) end |
.repent ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jericho.rb', line 48 def self.repent client = Slack::Web::Client.new client.chat_postMessage( channel: '#autotests', text: "Test run results for #{get_jenkins_job_name} #{$driver.caps[:deviceName]}, #{$driver.caps[:platformName]} #{$driver.caps[:platformVersion]}: Passed tests count: #{purify[:passed]}, Failed tests count: #{purify[:failed]},", attachments: [ { text: "*Failed tests*: #{'Test name and previous status:' + ("\n") + purify[:failed_tests].map { |t| t.values_at(:test_name, :previous_status) }.join("\n") } ", color: 'danger' } ], mrkdwn: true, as_user: true, ) end |
.reporter(parsed_report) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/jericho.rb', line 4 def self.reporter(parsed_report) list_of_scenarios_reports = {} parsed_report.each do |element| element['elements'].each do |scenario| scenario_status = 'Passed' scenario['steps'].each do |step| scenario_status = 'Failed' if step['result']['status'] != 'passed' end list_of_scenarios_reports[(scenario['name']).to_s] = scenario_status end end list_of_scenarios_reports end |