我正在考虑将 @high_priority 和 @low_priority 添加到我们的测试套件中的某些测试中,以便找出有多少高优先级(风险)测试失败了。理想情况下,我希望 Jenkins 中的测试作业旁边有一个列,显示
1/100 high priority and 8/60 low priority tests failed.
尽管如果有必要,我对控制台输出中的类似输出感到满意。
当前 Jenkins 作业正在运行命令行执行,例如:
cucumber --tags @AU_smoke ENVIRONMENT=beta --format html --out 'C:\git\testingworkspace\Reports\smoke_BETA_test_report.html' --format pretty
编辑: 添加额外的作业并不是真正的解决方案,我们有大量的作业运行所有测试的子集,因此为高优先级和低优先级添加额外的作业将需要将我们拥有的作业数量增加两倍。
最佳答案
我决定使用描述 setter 插件和额外列插件。这允许我将构建描述添加为我的 View 中的一列,并在我的代码中添加
After do |scenario|
if scenario.status.to_s=="passed"
$passed=$passed+1
elsif scenario.status.to_s=="failed"
$failed=$failed+1
puts "FAILED!"
elsif scenario.status.to_s=="undefined"
$undefined=$undefined+1
end
$scenario_count=$scenario_count+1
if scenario.failed?
Dir::mkdir('screenshots') if not File.directory?('screenshots')
screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A- Za-z_]/, '')}.png"
@browser.driver.save_screenshot(screenshot)
puts "Screenshot created: #{screenshot}"
embed screenshot, 'image/png'
#@browser.close
end
#@browser.close
end
at_exit do
end_time=Time.now
elapsed_time=end_time.to_i - $start_time.to_i
puts "\#description#scenarios total: #{$scenario_count}, passed: #{$passed}, failed: #{$failed}, known bug fails: #{$known_bug_failures}, undefined: #{$undefined}.#description#"
...
然后在描述 setter 插件中我使用正则表达式
/#description#(.+)#description#/
并使用第一个匹配组作为构建描述名称。这还允许我查看作业的构建历史记录,并一目了然地了解过去几周有多少测试以及通过了多少测试。
关于ruby - 显示因特定标签而失败的测试数量(Ruby、Cucumber、Jenkins),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15662198/