我正在写一个 gem,我想为它写很多测试,这是常态。我遵循了一些指南并得出以下结论:
耙文件
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << 'test'
end
desc "Run tests"
task :default => :test
测试/settings_test.rb
require "test/unit"
require "cohabit"
class SettingsTest < Test::Unit::TestCase
def test_thing
assert(false)
end
end
具有以下项目结构:
- cohabit
- lib
- cohabit
- ...
cohabit.rb
- test
settings_test.rb
我运行时得到以下信息rake test --trace
:
mbp4:cohabit mike.campbell$ rake test --trace
** Invoke test (first_time)
** Execute test
mbp4:cohabit mike.campbell$
和rake -T
:
mbp4:cohabit mike.campbell$ rake -T
rake build # Build cohabit-0.0.1.gem into the pkg directory.
rake default # Run tests
rake install # Build and install cohabit-0.0.1.gem into system gems.
rake release # Create tag v0.0.1 and build and push cohabit-0.0.1.gem to R...
rake test # Run tests
任何想法为什么我的测试似乎没有运行?我确定我可能错过了一些愚蠢的东西。
编辑 - 更改 Rakefile 和输出现在是:
mbp4:cohabit mike.campbell$ rake test --trace
** Invoke test (first_time)
** Execute test
/Users/mike.campbell/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -I"lib:test" -I"/Users/mike.campbell/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib" "/Users/mike.campbell/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.4/lib/rake/rake_test_loader.rb"