Reputation: 3768
I am using minitest with Jenkins to produce test reports. At the moment I am using Minitest::Reporters::JUnitReporter
- https://github.com/kern/minitest-reporters. This seems to give nice concise results.
The only thing missing is an embedded screenshot, specifically from failed tests.
How can I produce a Jenkins friendly test report that includes a screenshot? I am open to use one of the other Minitest::Reporters
if it helps.
Thanks
Upvotes: 0
Views: 463
Reputation: 26
You can use the capybara-screenshot gem for this: https://github.com/mattheworiordan/capybara-screenshot
Gemfile:
group :test do
gem 'capybara', '2.6.0'
gem 'selenium-webdriver', '2.49.0'
gem 'poltergeist', '1.8.1'
gem 'capybara-screenshot', '1.0.11'
end
test_helper.rb:
# default rails test configuration
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
# configure webtests with capybara and poltergeist (headless)
require 'capybara/rails'
require 'capybara/poltergeist'
require 'capybara-screenshot/minitest'
if ENV['HEADLESS'] == 'true'
# headless driver configuration
Capybara.default_driver = :poltergeist
else
Capybara.default_driver = :selenium
end
Capybara::Screenshot.prune_strategy = :keep_last_run # keep screenshots only from the last test run
Capybara.save_and_open_page_path = File.join(Rails.root, "test/screenshots") # where to save screenshots
# default test class for unit tests
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
# default test class for webtests
class ActionDispatch::IntegrationTest
include Capybara::DSL
include Capybara::Screenshot::MiniTestPlugin
end
Upvotes: 1