简体   繁体   English

Zentest-红色时如何停止自动测试

[英]Zentest - How to stop automatic testing when red

I am trying to configure autotest so that when I run my test suite and I have a failing test, autotest stops testing and waits for me to make a change before testing again. 我正在尝试配置自动测试,以便在运行测试套件且测试失败时,自动测试会停止测试并等待我进行更改,然后再进行测试。 With my current configuration autotest keeps testing indefinetly when it encounters a failing test making it a bit of a hassle to deal with (having to tab into terminal and stop the autotest server everytime I get a failing test). 使用我当前的配置,当自动测试遇到失败的测试时,它会一直不确定地进行测试,这使它有点麻烦(必须进入终端并在每次失败的测试中停止自动测试服务器)。

I am working on a rails app using RSpec, Zentest and Spork. 我正在使用RSpec,Zentest和Spork开发Rails应用程序。

Relevant Gem Versions: 相关宝石版本:

autotest (4.4.6)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
spork (0.9.0.rc8)
ZenTest (4.5.0)

My .autotest file: 我的.autotest文件:

module Autotest::Notify
  def self.notify title, msg, img, pri='low', time=3000
    `notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'`
  end

  Autotest.add_hook :ran_command do |autotest|
    results = [autotest.results].flatten.join("\n")
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
    folder = "~/.autotest_icons/"
    if output  =~ /[1-9]\d*\sfailures?/
      notify "FAIL:", "#{output}", folder+"failed.png", 'critical', 10000
    elsif output  =~ /[1-9]\d*\spending?/
      notify "PENDING:", "#{output}", folder+"pending.png", 'normal', 10000
    else
      notify "PASS:", "#{output}", folder+"passed.png"
    end
  end
end

Note: Most of my .autotest file was to get popups working in linux to display if my tests are passing or failing. 注意:我的大多数.autotest文件都是为了使弹出窗口在Linux中工作,以显示我的测试通过还是失败。

I have been searching for an answer to this problem for a while and have had no luck and I have found it very difficult to get my hands on some good documentation for Autotest. 我一直在寻找这个问题的答案,但是没有运气,我发现很难获得一些有关自动测试的好文档。 I have been staring at the RDoc for Zentest for quite a while now as well and I must just be missing something. 我也一直盯着Zentest的RDoc ,已经有一段时间了。

Any help, links to examples, etc, would be greatly appreciated. 任何帮助,链接到示例等,将不胜感激。

I had the same problem and found that my development server was writing to the log file. 我遇到了同样的问题,发现我的开发服务器正在写入日志文件。 After I added this to my .autotest file, the problem went away: 将其添加到.autotest文件后,问题消失了:

Autotest.add_hook :initialize do |at|
  at.add_exception(%r{^\./\.git})
  at.add_exception(%r{^\./log})
end

I saw a similar problem with ZenTest when I had a gem that was writing data to a directory that ZenTest was monitoring. 当我有一个gem将数据写入ZenTest监视的目录中时,我遇到了ZenTest的类似问题。 IIRC, it was a gem that did full-text searching -- the index file the search generated was triggering ZenTest to run again, thereby regenerating the index. IIRC,它是一个进行全文搜索的宝石-搜索生成的索引文件正在触发ZenTest再次运行,从而重新生成索引。

I tracked down the problem by modifying the Growl notifications to tell me which files were triggering the autotest run (I was running on a Mac at the time). 我通过修改Growl通知来跟踪问题,以告诉我哪些文件触发了自动测试运行(当时我在Mac上运行)。

The solution was to add an exception/exclude to the .autotest file, to tell it to ignore the index. 解决方案是在.autotest文件中添加一个例外/排除,以使其忽略索引。

(I've just seen : Spork is repeatedly re-running failing tests in autotest which sounds very similar to your problem) (我刚刚看到: Spork在自动测试中反复重新运行失败的测试,这听起来与您的问题非常相似)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM