Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何使用Unit::test在RubyonRails3.0.7中运行单个测试?_Ruby On Rails_Ruby On Rails 3_Unit Testing - Fatal编程技术网

Ruby on rails 如何使用Unit::test在RubyonRails3.0.7中运行单个测试?

Ruby on rails 如何使用Unit::test在RubyonRails3.0.7中运行单个测试?,ruby-on-rails,ruby-on-rails-3,unit-testing,Ruby On Rails,Ruby On Rails 3,Unit Testing,是的,我知道有人问过同样的问题(),但解决方案似乎对Rails3不起作用。也许它适用于Rails 2 如何使用Unit::test在Rails 3.0.7中运行单个测试?不是单个测试文件,而是单个测试 test "the truth" do assert false end ruby-I test test/functional/test_file.rb-n“真理”生成0个测试、0个断言、0个失败、0个错误试试看ruby-I(…)-n”方法只在Rails 3中对我有效,如下所示: bund

是的,我知道有人问过同样的问题(),但解决方案似乎对Rails3不起作用。也许它适用于Rails 2

如何使用Unit::test在Rails 3.0.7中运行单个测试?不是单个测试文件,而是单个测试

test "the truth" do
  assert false
end
ruby-I test test/functional/test_file.rb-n“真理”生成
0个测试、0个断言、0个失败、0个错误
试试看

ruby-I(…)-n”方法只在Rails 3中对我有效,如下所示:

bundle exec ruby -I test test/functional/test_file.rb -n "the truth"

不过,我还是在使用jRuby,所以YMMV

尝试正则表达式

bundle exec ruby -I test test/functional/test_file.rb -n "/truth/"

出于某种奇怪的原因,应该在测试行中使用下划线而不是空格,然后使用正则表达式。这对我来说很有用:

bundle exec ruby -I test test/functional/test_file.rb -n "/the_truth/"

我不能让它工作。文档很晦涩,我得到
无法修改冻结字符串
。这是一个很好的教程,介绍了如何使用单次测试(除其他选项外)。它还介绍了如何运行单个测试是的,我读过。它不起作用。他建议的两种方法是
ruby-I
和单测试gem。什么是
test
?我得到了
0个测试,0个断言,0个失败,0个错误
。我想你指的是“-I test”中的“test”-I test将RAILS\u ROOT/test目录添加到ruby加载路径。try bundle exec ruby-I test test/functional/test\u file.rb-n the \u truth抱歉,是的,我的意思是
-I test
。我收集到的是文本
test
。我做了
bundle exec ruby-I test test/functional/test_file.rb-n the_truth
,得到了
0个测试、0个断言、0个失败、0个错误。