Accidental Technologist

Musings about Entrepreneurship, Technology and Software Development

  • Home
  • About
  • Still River Software
  • Privacy Policy

Powered by Genesis

You are here: Home / Ruby on Rails / Minitest Not Running My Unit Tests

Minitest Not Running My Unit Tests

September 17, 2012 by Rob Bazinet 2 Comments

Tweet

I have started using minitest for Rails 3.x unit testing and since it comes with Ruby 1.9.x by default, it seems like a good direction to take my testing.

I am using the great gem by Mike Moore called minitest-rails which has a minitest dependency so I can easily have the latest version of minitest. ?This gem helps to more cleanly integrate and use minitest in our Rails 3.x projects.

As part of my setup I use Autotest so my tests run automatically when files change. ?I noticed none of my unit tests were running and upon further inspection, minitest was looking in test/unit and test/unit test directories but not in the test/models folder, which seems to be the minitest default. ?

Opening up my .autotest configuration file and adding the following:

Autotest.add_hook :initialize do |at|
?at.add_mapping(/test\/models\/.*\.rb/) do |_, m|
??at.files_matching %r%^test/(models)/.*\.rb$%
?end
end

After restarting autotest, my unit tests are now being tested. ?I hope this saves someone some time.

Share this:

  • LinkedIn
  • Twitter
  • Facebook
  • Email
  • More
  • Pinterest
  • Tumblr
  • Pocket
  • Reddit

Related

Filed Under: Ruby on Rails Tagged With: autotest, minitest, rails, Ruby, unit testing

Care about your privacy? I do and use Fathom Analytics on this site.

Fathom Analytics

Recent Posts

  • How to Fix Rails Flash Rendering When Using Hotwire
  • Hotwire Fix for CORS Error when using Omniauth
  • Fix Installation of Ruby using rbenv on macOS Big Sur
  • RailsConf 2021 and the Future of Conferences
  • Fixing Out of Diskspace Errors on Amazon EC2

Categories

Services I Love

HatchBox - Easy Rails Deploys Fathom Analytics
Follow @rbazinet

Rob Bazinet
@rbazinet

  • Exactly this…. https://t.co/yWj7fZ01HR
    about 1 day ago
  • https://t.co/EmagdpLoNv "Introducing GitHub Copilot X · GitHub"
    about 2 days ago
  • RIP Gordon Moore: https://t.co/c5J9LaHrj8
    about 2 days ago
  • Our daughter works as a teaching assistant at a local K-8 public school. It’s become apparent that students today r… https://t.co/p2t912GVyc
    about 2 days ago
  • Working to wrap up my current consulting gig by mid-April. I will be looking for the next thing soon. If anyone has… https://t.co/sg3cSV9yqM
    about 3 days ago
  • RSS - Posts
  • RSS - Comments
Find me on Mastodon