5

我试图用 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
4

2 回答 2

9

我忘了将此行添加到我的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
于 2013-01-16T16:29:20.010 回答
2

从 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
于 2014-11-09T21:51:46.163 回答