Minitest #setup and #teardown not called when test run via Rake Minitest #setup and #teardown not called when test run via Rake ruby ruby

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


The problem was that another test case was overwriting the setup and teardown methods. I had accidentally given two test cases the same class name, which is why the overwriting happened. Naturally, this error didn't happen when I ran a single test case, which explains the difference in behavior when using Rake.


In my case, I was writing tests for socket communication and had added a helper method named send. Since MiniTest uses send internally to call the teardown methods, it was instead calling my own send instead of the method-dispatch.