Created
February 29, 2020 12:37
-
-
Save prashanth-sams/b21423315279fd548cef1ae815f6af44 to your computer and use it in GitHub Desktop.
Export Ruby automation results to DataDog - RSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.configure do |config| | |
$data ||= [] | |
$passed = $failed = $pending = 0 | |
config.after(:each) do |scenario| | |
if (scenario.exception) && (!scenario.exception.message.include? 'pending') | |
status_id = 0 | |
elsif scenario.skipped? | |
status_id = 2 | |
elsif scenario.pending? | |
status_id = 2 | |
else | |
status_id = 1 | |
end | |
$data << {'status_id' => status_id, 'scenario' => scenario.description} | |
end | |
config.after(:all) do | |
$data.map do |value| | |
$failed += 1 if value['status_id'] == 0 | |
$passed += 1 if value['status_id'] == 1 | |
$pending += 1 if value['status_id'] == 2 | |
end | |
dog = Dogapi::Client.new(ENV['API_KEY'], ENV['APP_KEY']) | |
dog.batch_metrics do | |
dog.emit_point('qa.automation.passed', $passed) | |
dog.emit_point('qa.automation.failed', $failed) | |
dog.emit_point('qa.automation.pending', $pending) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment