Bug #12410
Updated by Dominic Cleal about 9 years ago
As per this webpage, http://theforeman.org/contribute.html#Setuptestenvironment To run a single test, you have to run: ruby -Itest test/functional/your_test.rb But that doesn't seem to work: <pre> $ ruby -Itest test/unit/orchestration/dhcp_test.rb /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- spork (LoadError) from /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/pphilip/git/foreman/foreman/test/test_helper.rb:2:in `<top (required)>' from /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from test/unit/orchestration/dhcp_test.rb:1:in `<main>' </pre> Is this something wrong with my environment? Instead, this works for me, but it seems like the tests are being executed twice. <pre> $ rake test TEST=test/unit/orchestration/dhcp_test.rb 2015-11-05T20:42:32 [app] [I] Connecting to database specified by database.yml The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls. The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls. Run options: --seed 34785 # Running tests: Finished tests in 0.001123s, 0.0000 tests/s, 0.0000 assertions/s. 0 tests, 0 assertions, 0 failures, 0 errors, 0 skips Loaded suite /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader Started ...............[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. .... Finished in 4.82911997 seconds. 19 tests, 64 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed 3.93 tests/s, 13.25 assertions/s Coverage report generated for Unit Tests to /home/pphilip/git/foreman/foreman/coverage. 57881 / 130558 LOC (44.33%) covered. /home/pphilip/.rvm/rubies/ruby-2.2.2/bin/ruby -I"lib:test" -I"/home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0" "/home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/unit/orchestration/dhcp_test.rb" /home/pphilip/git/foreman/foreman/test/test_runner.rb The Apipie cache is turned off. Enable it and run apipie:cache rake task to speed up API calls. Run options: --seed 34495 # Running tests: Finished tests in 0.001173s, 0.0000 tests/s, 0.0000 assertions/s. 0 tests, 0 assertions, 0 failures, 0 errors, 0 skips Loaded suite /home/pphilip/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader Started ...............[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. .... Finished in 4.805871891 seconds. 19 tests, 64 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed 3.95 tests/s, 13.32 assertions/s Coverage report generated for Unit Tests to /home/pphilip/git/foreman/foreman/coverage. 57912 / 130558 LOC (44.36%) covered. </pre> Let me know the right way to run a single test and I'll fix the documentation. -PP