Minitest #setup and #teardown not called when test run through Rake

I have a MiniTest package. I use the basic Minitest::Unit::TestCase , not the specs. I have setup and teardown methods defined in my TestCase subclass. They work fine when I run the test file as follows: ruby test/whatever_test.rb . But when I run rake test , setup and teardown not called. Relevant part of my rakefile:

 require 'rake/testtask' Rake::TestTask.new do |t| t.test_files = FileList['test/*_test.rb'] t.verbose = true end 

Why not run setup and teardown when using Rake::TestTask ?

I would enter the code for the test code here, but there are quite a lot of it. I will definitely enclose a few subsets if there is any section that you would like to see.

I am running Minitest 4.3.2 on Ruby 1.9.3-p194.

+7
source share
2 answers

The problem was that another test case was rewriting the setup and teardown . I accidentally gave two test cases the same class name, so there was a rewrite. Naturally, this error did not occur when I ran one test case, which explains the difference in behavior when using Rake.

+14
source

In my case, I wrote tests for socket communication and added a helper method called send . Since MiniTest uses send internally to call the teardown methods, instead of calling the method, it sent my own send .

+1
source

All Articles