我试图用TDD让我的头“脏”,出于某种原因,当我在命令行上运行bundle exec rake test
时,没有任何反应。
这是我的RakeFile
:
require 'rake/testtask'
Rake::TestTask.new do |test|
test.libs << 'test'
end
desc "Run Tests"
task :default => :test
这是我的测试文件:
require 'test/unit'
class TestMygem < Test::Unit::TestCase
def test_silly_example
assert_equal 2+2, 5
end
end
答案 0 :(得分:8)
我忘记将此行添加到RakeFile
test.test_files = FileList['tests/test_*.rb']
所以,总而言之,这是我的最终RakeFile
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.test_files = FileList['tests/test_*.rb']
end
desc "Run Tests"
task :default => :test
答案 1 :(得分:1)
从Rails 3.2.20开始,以下是可以接受的
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.pattern = 'test/_test*.rb'
t.verbose = false # or true
end
desc "Run Tests"
task :default => :test