我已經在幾個項目(嚴格的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
'assert_equal'是否需要2個參數?我希望看到一個'ArgumentError'異常,如果這是造成你的問題,但... – carols10cents