Print a list of all tests in a Rails application

Is there a simple ruby โ€‹โ€‹or rails command to list all the tests in an application? I use Shoulda in the first place, but if there is a ruby โ€‹โ€‹solution, regardless of the test suite, that will work too.

+4
source share
3 answers

I found a round robin solution: test_benchmarker plugin . You run your tests with an additional environment variable as follows:

rake test BENCHMARK_TESTS=true 

It is best to disable the output of the file to the file, because it will be long . But he will give you a list of all test classes and tests, both functional and functional. Obviously, this also gives you benchmarking results, which is a bonus.

Is there anything better? I think itโ€™s pretty close, and so little effort, why not get test results? RSpec has a built-in function, but it might be interesting to write a version for Test :: Unit.

+1
source

I donโ€™t think that there can be one answer to all the solutions: how the tests are identified is largely dependent on the structure. Once you get into a framework such as shoulda, itโ€™s almost impossible to identify all the tests without doing them, consider an example in which you, for example, have should requirements in a loop.

The listing of all tests as they start will consist of digging into the frame code for the point where individual tests are identified / generated and the necessary information is extracted.

I would be interested to know if (and how) I am wrong, though ...

0
source

I think you need it. This is what the rails test command does.

 tests = Rake::FileList["test/**/*_test.rb"] 
0
source

Source: https://habr.com/ru/post/1299030/


All Articles