How to run all tests with minitest?
Here's a link to Rake::TestTask.
There is an example in the page to get you started.
I'll post another one that I'm using right now for a gem:
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "spec/*_spec.rb"
end
As you can see, I assume that my files are all in /lib
and that my specs are in /spec
and are named whatever_spec.rb
Hope it helps.
How to run MiniTest::Unit tests in ordered sequence?
You can use i_suck_and_my_tests_are_order_dependent!()
class method.
class MyTest < MiniTest::Unit::TestCase
i_suck_and_my_tests_are_order_dependent! # <----
def test_1
p 1
end
def test_2
p 2
end
end
But as the name suggest, it's not a good idea to make the tests to be dependant on orders.
Is it possible to run a single test in MiniTest?
I'm looking for similar functionality to rspec path/to/file.rb -l 25
With Nick Quaranto's "m" gem, you can say:
m spec/my_spec.rb:25
How do I run a single test file in minitest?
bin/rails test test/controllers/issues_controller_test.rb
Rails: How to prepare test-DBs for parallelized tests with Minitest
Thanks to edariedl's hint I was able set up the parallelised testing. I had to grant global permissions to my dev-sql user. This is different from my usual setting, where I grant permissions only to the dev-database.
After granting global privileges to my dev-sql user:
mysql > GRANT ALL PRIVILEGES ON *.* TO user@localhost;
mysql > FLUSH PRIVILEGES;
Minitest does the rest and forks the testing. It creates n Databases, where n is the amount of cpu-cores of your system.
In my case this kind of parallelisation appears to be more solid and faster than threaded testing.
I want to call def setup method before all tests in minitest ruby
You can use minitest-hooks
gem with before_all
something like:
require "minitest/autorun"
require 'minitest/hooks/test'
class TestLogin < MiniTest::Test
include Minitest::Hooks
def before_all
puts "setup .."
end
def test_case1
puts "testcase1"
end
def test_case2
puts "testcase2"
end
end
Now when you run the test you should see something like:
Run options: --seed 58346
# Running:
setup ..
testcase1
.testcase2
.
Finished in 0.001259s, 1588.7504 runs/s, 0.0000 assertions/s.
2 runs, 0 assertions, 0 failures, 0 errors, 0 skips
Related Topics
Gem Eventmachine Fatal Error: 'Openssl/Ssl.H' File Not Found
Has Anyone Tried Installing Ruby & Rubygems from Source on Ubuntu (Preferably Ubuntu 9)
Installing Rvm (Ruby Version Manager)
How to Use Double Brackets in a Regular Expression
Rails - Best-Practice: How to Create Dependent Has_One Relations
Need to Split Arrays to Sub Arrays of Specified Size in Ruby
Ruby - Share Logger Instance Among Module/Classes
How to Serve Static Files via Rack
How to Calculate the Day of the Week of a Date in Ruby
How to Do Relative Time in Rails
How to Distinguish Xlsx and Docx Files from Zip Archives
A Method with an Optional Parameter
Database.Yml &References Not Working