2013-12-11 29 views
0

我已經在幾個項目(嚴格的Ruby和Rails)上使用Minitest,並沒有太多的問題。我只是用Minitest設置了一個Rails 4項目,並且由於某種原因無法運行測試。這一定是我的一個愚蠢的錯誤,但我看不到它。Minitest爲什麼不運行任何測試?

無論我使用rake還是ruby Itest,都會發生「錯誤」,「minitest running 0 tests」。

我也應該說我知道測試文件被識別,因爲如果我拿出描述塊,並且只有it should...,我會得到一個NoMethodError - undefined method "it" for CalendarMakerTest:Class

#test 

require 'test_helper' 

class CalendarMakerTest < ActionView::TestCase 

    describe "subject" do 
    it "does something" do 
     assert_equal false 
    end 
    end 

end 

#test_helper 

require 'minitest/autorun' 
require 'minitest/spec' 

ENV["RAILS_ENV"] ||= "test" 
require File.expand_path('../../config/environment', __FILE__) 
require 'rails/test_help' 


class ActiveSupport::TestCase 
    ActiveRecord::Migration.check_pending! 

end 

$ruby -Itest test/helpers/calendar_maker_test.rb 

Run options: --seed 33758 

# Running tests: 



Finished tests in 0.035027s, 0.0000 tests/s, 0.0000 assertions/s. 

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips 
+0

'assert_equal'是否需要2個參數?我希望看到一個'ArgumentError'異常,如果這是造成你的問題,但... – carols10cents

回答

1

你可以刪除行

class CalendarMakerTest < ActionView::TestCase 

隨着相應end聲明。你會有更好的運氣。

您正在混合使用Minitest的規格和自動測試方法。

當您需要minitest/autorun時,您在技術上也不需要require minitest/spec

+0

那是它,歡呼聲。你知道這是爲什麼導致這樣的行爲(沒有錯誤,但沒有運行測試)? – dax

+0

您創建一個類,然後調用describe,並且它不是它應該被調用的名稱空間。 – vgoff

相關問題