For my product I use rake for the test-case-execution based on Watir and Selenium. The execution is handled by Jenkins.
In the last two runs my test-suite has ran successful (0 errors/failures) anyway in the end of the log I can see, that rake throws and error anyway which leads to a negative run on jenkins because rake has not ended with RC0. Even if the rake message is "Rake aborted" the test-results are written and found by jenkins successfully.
Output:
96 tests, 3992 assertions, 0 failures, 0 errors, 0 skips
Writing XML reports to /home/test/admin/jenkins/system/workspace/projectname/Tests/results
rake aborted!
Version
> gem list rake
rake (12.0.0)
Updating rake to a new version is not possible at the moment because it is a company-wide used machine and for some reason this problem only occures for us.
Nothing more is printed out by rake.
Any ideas what could cause the problem or where to find more informations?
Related
I have a bunch of Ruby scripts and I'd like to start them with a Rake task.
A simplified version to illustrate my issue:
export_stats.rake:
desc 'Export statistics'
task :export_stats do
puts "executing: export_stats.rb #{START_MONTH} #{END_MONTH} #{OUTPUT} #{ENVIRONMENT}"
ruby "export_stats.rb #{START_MONTH} #{END_MONTH} #{OUTPUT} #{ENVIRONMENT}"
end
rake aborted! elk-stack/export_stats.rake Don't know how to build task
'export_stats'
the export_stats.rb file is in same directory with export_stats.rake
the rake gem is installed and if I run
rake export_stats
I get an error:
rake aborted!
Don't know how to build task 'export_stats'
What am I missing?
If I understand you correctly you have a folder with some ruby scripts and you are trying to run a rake task that is located in the same folder. I assume you are not using any application framework like Rails (because you did tag the question only with "Ruby").
Do you have a Rakefile in same directory? If so does it contain a statement to load the specific files to run?
# Rakefile
#!/usr/bin/env rake
load 'export_stats.rake'
You have a typo.
The code says export_stats, and the error says exports_stats.
There's an extra s.
Read the error message carefully! ;)
I've cloned rubygems repo (master branch), launched rake to run tests, and realized that there are a lot of failing specs (22 failures, 41 errors). More than that, sometimes tests running process hangs and doesn't continue until I hit ctrl+c. Am I doing something wrong, or is it intentional behavior?
UPD.
Also, I realized that amount of failures and errors differs from run to run. Tested on ruby 1.9.3 and 2.2.4.
I used jruby-1.7.0 and testing frame work Test::Unit::TestCase. Now I have updated some gems which caused me to use MiniTest::Test for testing, so I also upgraded to jruby-1.7.13. I have a rake task too which builds my gems with java *.class files instead of ruby *.rb files. Now many things dont work any more like 'rake test', or require "my_gem_xyz" from irb, getting errors like load error and ArrayIndexOutOfBoudsException. I have rvm installed to switch between rubies.
How can I use *.class files in my self made gems like it worked before under jruby-1.7.0? (If I include the *.rb files in the gem it seems to work ok)
Some time ago I tried with jruby-1.7.4 but that also failed with similar reasons (at that time I still used Test::Unit::TestCase, so the test frame work is not the problem)
Any ideas?
Frank
I found a surprising solution to the problem. I had compiled the *.rb classes with my jruby version 1.7.0's jrubyc. This caused the tests to fail with the load error. I had to compile all ruby classes with the jrubyc version 1.7.13 where I also build the gems.
update:
'rake test' still does not work comming up with errors like Mocha::ExpectationError: unexpected invocation: ...
what works is to use test options specifiying test file and test name (also with reg.exp.) like
rake test TEST=test/test_bla_bla.rb TESTOPTS="--name=/test_should_read/ -v"
I have the feeling the randomization with the seed parameter causes the problem. How can I influence the seed parameter?
update:
It looks like if there are too many tests in the test suite, MiniTest cannot handle this. In some cases I could run about 10 tests in some up to 35, using the TESTOPTS switch. I always fail if I run all tests in my test library with 'rake test'. This looks like a bug to me. Is there anybody who can help?
I am trying to get automated testing sorted out with Travis.ci. However, at the moment the build keeps on failing when trying to execute bundle exec rake.
This is what I see...
$ bundle exec rake
rake aborted!
Don't know how to build task 'default'
/home/travis/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/home/travis/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
The command "bundle exec rake" exited with 1.
Done. Your build exited with 1.
My unit tests are in the test folder in the main directory and is named test_np_search.rb. I understand that I am somehow supposed to point travis to this location in order to run the unit tests but I have no idea how to do this.
I have read the ruby related documentation on travis.ci a number of times and have looked online for tutorials, however I have been unable to get this to work.
The whole github repository in question is here: https://github.com/IsmailM/NeuroPeptideSearch
The Travis.CI link is here: https://travis-ci.org/IsmailM/NeuroPeptideSearch
I have been trying to get this sorted for over a week now with any success and so would be highly grateful if anyone could help me.
Many Thank
if you want to execute bundle exec rake on travis, you will have to make sure, that it runs on your local machine!
if you call rake without providing a task-name, it will assume that you want to run the default-task.
if you want to run your minitest testsuite as a default-task, you have to do this:
require "rake/testtask"
Rake::TestTask.new do |t|
t.pattern = "test/**/*_test.rb"
end
task default: :test
I am using Minitest as the runner for my functional tests, using Selenium as the driver to run the browser. Each test is modeled as MiniTest::Unit::TestCase.
Minitest reports summary of execution when it completes executing all tests. The Exceptions that were encountered are also printed towards the end of the execution. I find it difficult to debug when something unexpected fails as the context of execution is lost. The exceptions I am running into are not deterministic.
Is there a way to make Minitest runner to stop execution of tests on exception or assertion failure?
I am using minitest (2.11.2) and ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
I think you mean to have a "fast fail" option available. I found the fail_fast for minitest (Test::Unit): Immediate backtrace & exit article, but that's out of date (still covers what can be done). I think you'll need to monkeypatch your testing library to enable this option. I found a Gist showing how to add a simple fail-fast option to minitest/turn/minitest-rails so that might get you on the right track. I understand your problem is to do with the first article I've referenced:
When I run the Test::Unit suite in my Ruby on Rails 3 project through
rake test and a test is failing, the default behavior is to just
print āFā or āEā, keep running until all the tests are finished (while
I twiddle my thumbs), and only then print out a stack trace.
try rails test -f will do it. It means abort test run of first failure or error.
As I answered here, I found a gem for: minitest-fail-fast. It works with Rails 4.2 and Minitest 5.6.1
It does not directly answer the question, but might be very useful.
You could use pry-rescue gem so that your tests will launch a pry session whenever something goes wrong. All you have to do is to add the gem into your Gemfile:
group :development, :test do
gem 'pry-rescue'
end
Then launch your tests with the following flag:
PRY_RESCUE_RAILS=1 rails test rails test test/integration/agendas_test.rb
Use -f.
In pure ruby, as you ask for, this means ruby <file> -f.
In rails, this means rails test -f.
Minitest will check the terminal's arguments for the -f flag, so how you call it appears to not be relevant to the -f flag.