显示使用特定标记失败的测试数(Ruby,Cucumber,Jenkins)

时间:2013-03-27 15:06:04

标签: ruby jenkins cucumber

我正在考虑将@high_priority和@low_priority添加到我们的测试套件中的某些测试中,以便找出有多少高优先级(风险)测试失败。理想情况下,我想在显示

的测试作业旁边的Jenkins中找到一列
  

1/100高优先级和8/60低优先级测试失败。

虽然如果有必要,我对控制台输出中的类似输出感到满意。

目前,Jenkins作业正在运行命令行执行,如:

cucumber --tags @AU_smoke ENVIRONMENT=beta --format html --out 'C:\git\testingworkspace\Reports\smoke_BETA_test_report.html'  --format pretty

编辑: 添加额外的工作并不是真正的解决方案,我们有大量的工作来运行所有测试的子集,因此为高优先级和低优先级添加额外的工作需要将我们拥有的工作数量增加三倍。

1 个答案:

答案 0 :(得分:2)

我已经决定使用描述setter插件和额外的列插件。这允许我在我的视图和我的代码中添加构建描述作为列

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#/ 

并使用第一个匹配组作为构建描述名称。这也让我可以看一下工作的构建历史,一眼就能看到有多少测试,以及过去几周传递了多少测试。