如何使用 minitest-reporters 嵌入截图
How to embed a screenshot with minitest-reporters
我正在使用 minitest 和 Jenkins 来生成测试报告。目前我正在使用 Minitest::Reporters::JUnitReporter
- https://github.com/kern/minitest-reporters。这似乎给出了很好的简洁结果。
唯一缺少的是嵌入式屏幕截图,特别是来自失败测试的屏幕截图。
如何生成包含屏幕截图的 Jenkins 友好测试报告?如果有帮助,我愿意使用其他 Minitest::Reporters
之一。
谢谢
您可以为此使用水豚截图 gem:https://github.com/mattheworiordan/capybara-screenshot
宝石文件:
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
我正在使用 minitest 和 Jenkins 来生成测试报告。目前我正在使用 Minitest::Reporters::JUnitReporter
- https://github.com/kern/minitest-reporters。这似乎给出了很好的简洁结果。
唯一缺少的是嵌入式屏幕截图,特别是来自失败测试的屏幕截图。
如何生成包含屏幕截图的 Jenkins 友好测试报告?如果有帮助,我愿意使用其他 Minitest::Reporters
之一。
谢谢
您可以为此使用水豚截图 gem:https://github.com/mattheworiordan/capybara-screenshot
宝石文件:
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