Ruby 中的 Selenium-Webdriver 和 minitest。 Rake 只运行一个 Dir.glob 的文件
Selenium-Webdriver in Ruby with minitest. Rake only runs one file with Dir.glob
我似乎无法使用 Minitest 制作 Rake 运行 我所有的测试套件,它只有 运行s 文件 file_b.rb,想不通为什么。
我在该路径中有两个文件,file_a.rb 和 file_b.rb,都有 4 个测试用例每个。
首先我尝试了:
task :default => :test
task :test do
Dir.glob('./path/to/file_*.rb').each { |file| require file}
end
和输出:
$ N=4 rake
Run options: --seed 22083
# Running:
....
Finished in 30.830958s, 0.1297 runs/s, 0.0000 assertions/s.
4 runs, 0 assertions, 0 failures, 0 errors, 0 skips
也一样
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "spec/2.3/web_v5_pc_qubit_*.rb"
end
输出:
$N=4 rake test
Run options: --seed 36188
# Running:
....
Finished in 18.307436s, 0.2185 runs/s, 0.0000 assertions/s.
4 runs, 0 assertions, 0 failures, 0 errors, 0 skips
我已经弄明白了。主要问题是目录中的 Rakefile 和文件没有与 Minitest 一起使用的正确路径和文件名约定。
这个 Rakefile 解决了这个问题:
require 'rake/testtask'
Rake::TestTask.new(:all) do |t|
t.libs << "tests"
t.test_files = FileList['tests/test_*.rb']
t.verbose = true
end
Rake::TestTask.new(:webpc) do |t|
t.libs << "tests"
t.test_files = FileList['tests/test_web_*.rb']
t.verbose = true
end
task default: :all
我似乎无法使用 Minitest 制作 Rake 运行 我所有的测试套件,它只有 运行s 文件 file_b.rb,想不通为什么。
我在该路径中有两个文件,file_a.rb 和 file_b.rb,都有 4 个测试用例每个。
首先我尝试了:
task :default => :test
task :test do
Dir.glob('./path/to/file_*.rb').each { |file| require file}
end
和输出:
$ N=4 rake
Run options: --seed 22083
# Running:
....
Finished in 30.830958s, 0.1297 runs/s, 0.0000 assertions/s.
4 runs, 0 assertions, 0 failures, 0 errors, 0 skips
也一样
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "spec/2.3/web_v5_pc_qubit_*.rb"
end
输出:
$N=4 rake test
Run options: --seed 36188
# Running:
....
Finished in 18.307436s, 0.2185 runs/s, 0.0000 assertions/s.
4 runs, 0 assertions, 0 failures, 0 errors, 0 skips
我已经弄明白了。主要问题是目录中的 Rakefile 和文件没有与 Minitest 一起使用的正确路径和文件名约定。
这个 Rakefile 解决了这个问题:
require 'rake/testtask'
Rake::TestTask.new(:all) do |t|
t.libs << "tests"
t.test_files = FileList['tests/test_*.rb']
t.verbose = true
end
Rake::TestTask.new(:webpc) do |t|
t.libs << "tests"
t.test_files = FileList['tests/test_web_*.rb']
t.verbose = true
end
task default: :all