Is it possible to enhance the rake test task and m

2019-04-15 03:05发布

I am writing tests for my sidekiq workers and I want them to run when I type "rake" in the terminal. I have that working - I added the following to my Rakefile:

namespace :test do
  Rake::TestTask.new(:workers) do |t|
    t.libs << "test"
    t.pattern = 'test/workers/**/*_test.rb'
  end
end

Rake::Task[:test].enhance ["test:workers"]

When I run rake I get something like this as my output:

Run options: --seed 51172

# Running tests:

SS

Finished tests in 0.005594s, 357.5259 tests/s, 0.0000 assertions/s.

2 tests, 0 assertions, 0 failures, 0 errors, 2 skips
Run options: --seed 17561

# Running tests:

S............................................SSSS..SSSSS......

Finished tests in 2.037526s, 30.4291 tests/s, 45.6436 assertions/s.

62 tests, 93 assertions, 0 failures, 0 errors, 10 skips

The S characters are skips - I haven't finished all of my tests yet. So my question is basically - is there a way to merge the two sets of tests after enhancing? Should I be doing something different than an enhance?

If I'm doing anything blatantly wrong please let me know, and thanks for reading this. And just in case it is needed: Rails 4 w/ Ruby 2.0

2条回答
手持菜刀,她持情操
2楼-- · 2019-04-15 03:26

there is a simple workaround for this:

bundle exec rake test:all

if you want to see how rails tasks are created look here

查看更多
相关推荐>>
3楼-- · 2019-04-15 03:32

Try this, change the following:

Rake::TestTask.new(:workers) do |t|

to this:

Rails::TestTask.new(:workers) do |t|

It's a small change, but fixes the problem for me. It means your entire test suite will run with merged output.

查看更多
登录 后发表回答