Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minitest is not running setup method for all files

When I run Minitest in rails with more than one file, the setup method is only run for one class.

For example, if I run rails test test/controllers, I get the expected results. None of the controller tests have a setup method.

However, if I run rails test test/models, then the first file executed runs correctly (it contains a setup method), but the second file's setup method doesn't ever run. If I run each model test separately, they behave as expected.

Any idea what I'm doing wrong?

like image 490
Zack Avatar asked Dec 17 '25 23:12

Zack


1 Answers

It turns out that I'm an idiot. I created the test files for my model helpers by copying a template file. When I did this, I forgot to change the class names. Thus, I had several test rb files that all contained the same class. Because ruby has open classes, this had the effect of adding the tests from each file to a single class but each subsequent file replaced the previous file's setup method. 🤦

like image 140
Zack Avatar answered Dec 20 '25 17:12

Zack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!