2010-12-01 8 views
0

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

非統合テストでは、テストを変更すると同じスペックファイル(またはブロックを記述する)でテストを再実行するというパターンです。その説明。つまり、page_controller.rbとpage_controller_spec.rbがあるとします。 autotestは、これらのファイルのいずれかを変更すると、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 

答えて

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 
+0

年後ですが、にもかかわらずありがとうございます。 –

-1

申し訳ありませんが、私は完全にあなたの問題を解決する時間がありませんが、私はあなたがオートテスト#1 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 
+0

あまり役に立ちません。ここのコメントは誤解を招きます。この場合、一致したファイル名を返すだけです。 – szeryf

関連する問題