我可以在一个文件中运行所有测试:

rake test TEST=path/to/test_file.rb

但是,如果我只想在该文件中运行一个测试,我该怎么做呢?

我正在寻找类似的功能:

rspec path/to/test_file.rb -l 25

当前回答

你有没有试过:

ruby path/to/test_file.rb --name test_method_name

其他回答

不需要宝石: ruby - test test/lib/testRb——name /some_test/

来源:http://blog.arvidandersson.se/2012/03/28/minimalicous-testing-in-ruby-1-9

命令应该是:

% rake test TEST=test/test_foobar.rb TESTOPTS="--name=test_foobar1 -v"

我正在寻找类似的功能: / / test_file rspec路径。Rb -l 25

有一种宝石正是这样做的:最小行。

gem install minitest-line
ruby test/my_file -l 5

从https://github.com/judofyr/minitest-line minitest-line

我在Rails版本4.2.11.3和Ruby版本2.4.7p357

下面一个对我有用。

ruby -Itest <relative_minitest_file_path> --name /<test_name>/

你有没有试过:

ruby path/to/test_file.rb --name test_method_name