如何在Minitest中获得测试摘要?

时间:2017-07-18 08:18:54

标签: ruby watir minitest

我已使用WatirMinitest自动完成了网络测试。我在运行测试后得到了这个摘要。

  

以417.061643s结束,0.0168次/秒,0.0719次断言/秒。

     

1)失败:   Map#test_maps_analysis_mode_ku060s [C:/ Projects / Cbs Sandbox / tests / watir / map.rb:63]:   使用的总模具。   预计:“103”

     

实际:“102”

     

2)错误:   地图#test_maps:   Watir :: Wait :: TimeoutError:10秒后超时,等待#“overlay”}上的错误条件>

     

7次运行,30次断言,1次失败,1次错误,0次跳过

我需要在电子邮件中获取摘要。如果可能,我还想包括成功的测试列表。

怎么做?

1 个答案:

答案 0 :(得分:1)

使用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记者(最好是在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

然后您可以解析结果。

相关问题