Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run all tests with minitest?

Tags:

ruby

minitest

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.

like image 976
guai Avatar asked Jan 24 '11 23:01

guai


People also ask

How do you run a test with a Minitest?

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.

Is Minitest part of Ruby?

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.

How do I run a test case in Rails?

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.


1 Answers

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.

like image 136
locks Avatar answered Oct 13 '22 22:10

locks