Rake TestTask不会运行单元测试

时间:2013-11-22 16:57:13

标签: ruby unit-testing rake testunit

我的rake TestTask看起来像这样

Rake::TestTask.new(:tasks) do |t|
  t.libs << "test"
  t.test_files = FileList['tasks/tasks*.rb']
  t.verbose = true
end

我的单元测试命名为tasks01.rb,如下所示

require_relative '../../class_based_page_objects/tasks/add_task'
require_relative '../../class_based_page_objects/tasks/tasks_grid_view'
require_relative '../../helpers/ssh_test_session'
require_relative '../../class_based_page_objects/login'

require "test-unit"
gem "test-unit"
require "selenium-webdriver"

puts "Will you print this?"

class Task01Test < Test::Unit::TestCase

  def setup
    #test Setup goes here 
    puts "Setup"
  end

  def test_assign_to_not_real_user
    # Test goes here 
    puts "Test"
  end
end

当我

rake tasks

我得到了

"Will you print this?"

我错过了什么?

1 个答案:

答案 0 :(得分:0)

你只需要在你的Rakefile代码中有一个描述行,如下所示:

desc "A description here without a period"
Rake::TestTask.new(:tasks) do |t|
  t.libs << "test"
  t.test_files = FileList['tasks/tasks*.rb']
  t.verbose = true
end