如何在Minitest中获取测试摘要?
How to get test summary in Minitest?
我已经使用 Watir and Minitest 自动化了我的 Web 测试。我在 运行 测试后得到了这个总结。
Finished in 417.061643s, 0.0168 runs/s, 0.0719 assertions/s.
1) Failure:
Map#test_maps_analysis_mode_ku060s [C:/Projects/Cbs Sandbox/tests/watir/map.rb:63]:
Total die used.
Expected: "103"
Actual: "102"
2) Error:
Map#test_maps:
Watir::Wait::TimeoutError: timed out after 10 seconds, waiting for false condition on #"overlay"}>
7 runs, 30 assertions, 1 failures, 1 errors, 0 skips
我需要通过电子邮件获取摘要。如果可能的话,我还想包括成功的测试列表。
怎么做?
使用 Rake 运行 将所有测试作为一个 ruby 应用程序。
首先,gem install rake
然后将名为 'Rakefile' 的文件添加到您的根项目文件夹中,代码类似于:
require "rake/testtask"
Rake::TestTask.new do |t|
t.test_files = FileList['tests/**/*_test.rb'] #my directory to tests is 'tests' you can change at you will
end
desc "Run tests"
task default: :test
在项目的某处添加一个简单的控制台 minitest reporter(最好在 test_helper.rb 中,它是所有测试的超类):
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
最后,我使用下一个批处理脚本将日志存储在文件中:
Type NUL > results.log
call rake >> results.log
在 results.log 文件的末尾提供了测试摘要 运行:
Finished in 631.09969s
47 tests, 105 assertions, 10 failures, 0 errors, 0 skips
然后您可以解析结果。
我已经使用 Watir and Minitest 自动化了我的 Web 测试。我在 运行 测试后得到了这个总结。
Finished in 417.061643s, 0.0168 runs/s, 0.0719 assertions/s.
1) Failure: Map#test_maps_analysis_mode_ku060s [C:/Projects/Cbs Sandbox/tests/watir/map.rb:63]: Total die used. Expected: "103"
Actual: "102"
2) Error: Map#test_maps: Watir::Wait::TimeoutError: timed out after 10 seconds, waiting for false condition on #"overlay"}>
7 runs, 30 assertions, 1 failures, 1 errors, 0 skips
我需要通过电子邮件获取摘要。如果可能的话,我还想包括成功的测试列表。
怎么做?
使用 Rake 运行 将所有测试作为一个 ruby 应用程序。
首先,gem install rake
然后将名为 'Rakefile' 的文件添加到您的根项目文件夹中,代码类似于:
require "rake/testtask"
Rake::TestTask.new do |t|
t.test_files = FileList['tests/**/*_test.rb'] #my directory to tests is 'tests' you can change at you will
end
desc "Run tests"
task default: :test
在项目的某处添加一个简单的控制台 minitest reporter(最好在 test_helper.rb 中,它是所有测试的超类):
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
最后,我使用下一个批处理脚本将日志存储在文件中:
Type NUL > results.log
call rake >> results.log
在 results.log 文件的末尾提供了测试摘要 运行:
Finished in 631.09969s
47 tests, 105 assertions, 10 failures, 0 errors, 0 skips
然后您可以解析结果。