0

自動テストを使用しており、統合テストを実行するためのフックを追加しました。作業中、統合テストのいずれかに影響を与える変更を加えると、すべての統合テストが再実行されます。これは、可能であれば変更したい動作です。(私はテストにwebratでrspecを使用していますが、キュウリは使用していません)

非統合テストでは、テストまたはその記述を変更した場合に、同じスペックファイル(またはdescribeブロック?)でテストを再実行するというパターンがあります。したがって、page_controller.rbとpage_controller_spec.rbがあるとします。autotestは、これらのファイルの1つを変更すると、page_controller_specのテストのみが実行され、合格すると、すべてのテストが実行されることを認識しています。統合テストにも同様のものが必要です。最初に失敗したテストを含むファイルでテストを実行し、合格した場合はすべてのテストを実行します。

私の.autotestファイルは次のようになります

require "autotest/growl"
require "autotest/fsevent"

Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/integration\/.*_spec\.rb$/) do
    autotest.files_matching(/^spec\/integration\/.*_spec\.rb$/)
  end  
end
4

2 に答える 2

1

あなた.autotestが問題の原因です:)それは基本的に、ディレクトリ内のすべてのファイルに対して、それらすべてを実行する必要があることを示しています。次のように、一致したファイル名のみを返す必要があります。/spec/integration

require "autotest/growl"
require "autotest/fsevent"

Autotest.add_hook :initialize do |autotest|
  autotest.add_mapping(/^spec\/integration\/.*_spec\.rb$/) do |filename|
    filename
  end  
end
于 2012-04-14T14:31:58.207 に答える
-1

申し訳ありませんが、あなたの問題を完全に解決する時間はありませんが、Autotest#add_mapping メソッドのコメントを読むと、自分で解決できると思います。正規表現で少し遊ぶ必要があります。「+proc+ は一致するファイル名と Regexp.last_match を渡す」に注意してください。ここに完全なコメントがあります:

  # Adds a file mapping, optionally prepending the mapping to the
  # front of the list if +prepend+ is true. +regexp+ should match a
  # file path in the codebase. +proc+ is passed a matched filename and
  # Regexp.last_match. +proc+ should return an array of tests to run.
  #
  # For example, if test_helper.rb is modified, rerun all tests:
  #
  #   at.add_mapping(/test_helper.rb/) do |f, _|
  #     at.files_matching(/^test.*rb$/)
  #   end

  def add_mapping regexp, prepend = false, &proc
于 2011-03-01T18:59:49.847 に答える