I downloaded source code for a project, found a bug, and fixed it.
Now I want to run tests to find out if I have broken anything.
The Tests are in minitest DSL.
How do I run them all at once?
I searched for applicable rake tasks etc, but I didn't find any.
To run a Minitest test, the only setup you really need is to require the autorun file at the beginning of a test file: require 'minitest/autorun' . This is good if you'd like to keep the code small. A better way to get started with Minitest is to have Bundler create a template project for you.
Minitest is a testing tool for Ruby that provides a complete suite of testing facilities. It also supports behaviour-driven development, mocking and benchmarking. With the release of Ruby 1.9, it was added to Ruby's standard library, which increased its popularity.
Or we can run a single test file by passing the bin/rails test command the filename containing the test cases. This will run all test methods from the test case. You can also run a particular test method from the test case by providing the -n or --name flag and the test's method name.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With