guard/guard-minitest

guard-minitest falsely claims there are 0 tests to run

Closed this issue · 4 comments

jottr commented
$ ruby hamming_test.rb
# ...
15 runs, 0 assertions, 0 failures, 2 errors, 13 skips

BUT:

$ guard
# ...
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips
$ guard -d
# ...
23:33:20 - DEBUG - Running: ruby -I"test" -I"spec" -r minitest/autorun -e "" --
# ...
# ./Guardfile
guard :minitest do
  # with Minitest::Unit
  watch('hamming.rb') {'hamming_test.rb'}
  watch('hamming_test.rb')
end
#./Gemfile.lock
# ...
guard (2.13.0)
guard-minitest (2.4.4)
# ...
$ ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.3
BuildVersion:   15D21
e2 commented

ruby -I"test" -I"spec" -r minitest/autorun -e ""

What if you run just that command instead of guard?

jottr commented
$ ruby -I"test" -I"spec" -r minitest/autorun -e ""
#...
0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

When I edit it as follows, the tests are run:

$ ruby -I"-r minitest/autorun -e " hamming_test.rb
# ...
15 runs, 0 assertions, 0 failures, 2 errors, 13 skips
$ tree
.
├── Guardfile
├── README.md
├── hamming.rb
└── hamming_test.rb

0 directories, 4 files
e2 commented

The files have to be within directories specified with the test_folders option.

Your file hamming_test.rb is neither in spec nor test, so it's ignored.

See: https://github.com/guard/guard-minitest#test_folders-and-test_file_patterns

I'd suggest just moving hamming_test.rb to a test subdirectory.

And change the watches to handle this.

jottr commented

Thx for the info. Instead of moving the files, I did:

guard :minitest, test_folders: './', test_file_patterns: '*_test.rb' do
which made more sense in my particular case.