Search code examples
rubyseleniumrakeminitest

Selenium-Webdriver in Ruby with minitest. Rake only runs one file with Dir.glob


I can't seem to make Rake run all my test suites with Minitest, it only runs file file_b.rb, and can't figure it out why.

I have two files in that path, file_a.rb and file_b.rb, both have 4 test cases each.

First I tried:

task :default => :test
task :test do
  Dir.glob('./path/to/file_*.rb').each { |file| require file}
end

and the output:

$ 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

And the same for

require 'rake/testtask'

Rake::TestTask.new do |t|
  t.pattern = "spec/2.3/web_v5_pc_qubit_*.rb"
end

Output:

$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

Solution

  • I've figured it out. The main problem was the Rakefile and files in the directory to not having the correct path and filename convention used with Minitest.

    This Rakefile solved the issue:

    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