Unable to attach test reporter to test framework or test framework quit unexpectedly
I am so totally beside myself. I am tryingt to run the simplest of tests. Granted I am a total noob, but still I cannot beleive that this does not work out ofthe box. Tried following all the "suggestions" here, but still cannot get this darn thing to work.
Here is my test file (taken from the wonderful tutorial of Mister Neighborly). The tests are running fine, but I am getting the dreaded message above.
require "test/unit"
require_relative "mac_addr"
class MyTest < Test::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
# Do nothing
end
# Called after every test method runs. Can be used to tear
# down fixture information.
def teardown
# Do nothing
end
# Fake test
def test_fail
# To change this template use File | Settings | File Templates.
#fail("Not implemented")
end
def test_tos
assert_equal("FF:FF:FF:FF:FF:FF",
MacAddr.new("FF:FF:FF:FF:FF:FF").to_s)
assert_not_equal("FF:00:FF:00:FF:FF",
MacAddr.new("FF:FF:FF:FF:FF:FF").to_s)
end
end
Thank you
Please sign in to leave a comment.
Hi,
what ruby version you are using? If 1.9 then most likely you do use minitest tst framework
and you need add some bits to be able to see results in RM. Here is a help topic about it - http://www.jetbrains.com/ruby/webhelp/minitest.html
Hope this helps, Oleg.
OK. I tried to follow the instructions. And now I am getting
in `runner': undefined method `runner' for MiniTest::Unit:Class (NoMethodError.
Now what am I doing wrong? Thanks for your prompt response
Could you, please, provide whole contgent of run console (at least whole stacktrace).
Or, if it is possible, test project.
Thanks, Oleg.
sure:
here is stack trace:
/home/dagills/.rvm/rubies/ruby-1.9.2-p320/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/dagills/RubymineProjects/second/my_test.rb
Testing started at 12:43 PM ...
/home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporter.rb:4:in `runner': undefined method `runner' for MiniTest::Unit:Class (NoMethodError)
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters/progress_reporter.rb:22:in `initialize'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `new'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `use!'
from /home/dagills/RubymineProjects/second/my_test.rb:3:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
Attached zip with entire project directory. I'm sure it will be something extremely stupid, but thanks for your patience
Attachment(s):
second.tar.gz
The code throws different error for me:(
second/my_test.rb:6:in `<top (required)>': uninitialized constant Test (NameError)
if replace Test::Unit::TestCase with MiniTest::Unit::TestCase and add "require 'minitest/autorun'" everything works fine for me :(
What is your gem environament (Tools|Show Gem Environment)?
BTW are you sure that you use minitest? Perhaps you are using test-unit?
Regards, Oleg.
P.S. IMHO it would be much easier to use bundler to have better control on you gem environment.
Thanks for trying to help out. I was trying to use both mini-test and test-unit to see which one works better for me. Since I was able to at least get test-unit running, I stuck with it.
As for using Bundler, you are right. I did tell you, though, that I was just starting...
So let's resort to using minitest only.
Here is the Gem environment:
RUBYGEMS VERSION: 1.8.24
RUBY VERSION: 1.9.2 (2012-04-20 patchlevel 320) [i686-linux]
INSTALLATION DIRECTORY: /home/dagills/.rvm/gems/ruby-1.9.2-p320
RUBY EXECUTABLE: /home/dagills/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
EXECUTABLE DIRECTORY: /home/dagills/.rvm/gems/ruby-1.9.2-p320/bin
RUBYGEMS PLATFORMS:
ruby
x86-linux
GEM PATHS:
/home/dagills/.rvm/gems/ruby-1.9.2-p320
/home/dagills/.rvm/gems/ruby-1.9.2-p320@global
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:benchmark => false
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
http://rubygems.org/
----------------------
IDE: JetBrains RubyMine 4.5.4, build #RM-119.71
OS: Linux 3.5.0-19-generic[i386]
Java: 1.7.0_10-b18
RubyMine SDK Environment:
Sdk: RVM: ruby-1.9.2-p320
Sdk Version: ver.1.9.2p320 ( revision 35421) p320
Ruby Interpreter: /home/dagills/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
RVM Sdk: yes, gemset:[default]
RVM Home: /home/dagills/.rvm
Sdk Language Level: 1.9
Sdk Load Path:
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/i686-linux
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/vendor_ruby/1.9.1
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/vendor_ruby/1.9.1/i686-linux
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/vendor_ruby
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1
~/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/i686-linux
~/RubyMine-4.5.4/rubystubs19
Sdk Gem paths:
~/.rvm/gems/ruby-1.9.2-p320/bundler/gems
~/.rvm/gems/ruby-1.9.2-p320/gems
~/.rvm/gems/ruby-1.9.2-p320@global/gems
Gems used for 'second': must admit I am a bit puzzled here; Dont know why this section is empty when in my Project settings I have an entire list of Gems that I am using. Screenshot attached.
/home/dagills/.rvm/rubies/ruby-1.9.2-p320/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/dagills/RubymineProjects/second/my_test.rb
Testing started at 3:55 PM ...
/home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporter.rb:4:in `runner': undefined method `runner' for MiniTest::Unit:Class (NoMethodError)
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters/progress_reporter.rb:22:in `initialize'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `new'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `use!'
from /home/dagills/RubymineProjects/second/my_test.rb:4:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
I went through the steps you told me; . Still same problem:
/home/dagills/.rvm/rubies/ruby-1.9.2-p320/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/dagills/RubymineProjects/second/my_test.rb
Testing started at 3:55 PM ...
/home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporter.rb:4:in `runner': undefined method `runner' for MiniTest::Unit:Class (NoMethodError)
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters/progress_reporter.rb:22:in `initialize'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `new'
from /home/dagills/.rvm/gems/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporters.rb:21:in `use!'
from /home/dagills/RubymineProjects/second/my_test.rb:4:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
Attachment(s):
SDK and Gems.zip
Hi,
I was able to reproduce the problem and found simple workaround: add "require 'minitest/autorun'" before "require 'minitest/reporters'".
(you need it anyway to make the test runnable ;)).
As for empty list of gems used for the project: it looks like we have some problem here, I've seen this when the problem was reproducible, but at some point
we have identified all gems the app need and the problem disappear :( Will try to find the root cause of the problem.
Hoep the workaround help.
Regards, Oleg.
Sorry :(
Still getting the exact same issue.
Difficult for me to understand why changing the order ofthings should help, but regardless, it does show that there is indeed a problem here, and only so much of it can be attributed to my noobiness.
Any other ideas?
Perhaps you can send me the exact project files which got your attempts to work. Other than that it must be some kind of global setup.
Regardless, I would very much appreciate trying to find a solution for this. Rubymine is kind of unusable without being able to run its unit tests from within the IDE.
Thank you
Well, I think Ihave finally found way to workaround the problem. you sould also add "gem 'minitest'" at the top of the test.
Here is my version of the test:
require_relative "mac_addr"
gem 'minitest'
require 'minitest/autorun'
require 'minitest/reporters'
MiniTest::Reporters.use!
class MyTest < MiniTest::Unit::TestCase
# Called before every test method runs. Can be used
# to set up fixture information.
def setup
# Do nothing
end
# Called after every test method runs. Can be used to tear
# down fixture information.
def teardown
# Do nothing
end
# Fake test
def test_fail
# To change this template use File | Settings | File Templates.
#fail("Not implemented")
end
def test_tos
assert_equal("FF:FF:FF:FF:FF:FF",
MacAddr.new("FF:FF:FF:FF:FF:FF").to_s)
assert_not_equal("FF:00:FF:00:FF:FF",
MacAddr.new("FF:FF:FF:FF:FF:FF").to_s)
end
end
The order of require is important because minitest-reporters uses monkey-patching (assuming that minitest has been loaded efore this)
Regards, Oleg.
P.S. I'd strongly recommend you to use bundler it will simplify your life a lot ;)
sorry dude.
I appreciate your effort, but still the exact exact exact same thing. I am starting to feel like perhaps we are shooting in the dark here, or that something is really really wrong with me, or perhaps something is really really wrong with this software.
Its a shame, this was going to be the tool I was going to use in school and introduce to all the members of my faculty.
However we are all non-programmers, and this tool is probably way over our heads.
I mean if doing something as simple as what I am trying to do requires an army of the brightest people to try and accomplish and they can still not do that, I guess that it means that the tool is only for experienced people, and I am NOT one of them.
You are telling me to use bundler. I will, I promise, after I get this issue resolved. I first need to learn how to crawl.
Thank you
Are you able to run the test from command line?
$ rvm current
ruby-1.9.2-p320@minitest-test
$ gem list
*** LOCAL GEMS ***
ansi (1.4.3)
builder (3.1.4)
bundler (1.2.3)
debugger-ruby_core_source (1.1.5)
hashie (1.2.0)
minitest (4.3.3)
minitest-reporters (0.13.1)
powerbar (1.0.11)
rake (10.0.3)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)
test-unit (2.5.3)
$ ruby my_test.rb
Started
ERROR MyTest#test_tos (0.00s)
undefined method `assert_not_equal' for #<MyTest:0x00000002858c28>
my_test.rb:33:in `test_tos'
2/2: [=======================================================================================================================================================================================] 100% 00:00:00
Finished in 0.01147s
2 tests, 1 assertions, 0 failures, 1 errors, 0 skips
And the test project is attached.
BTW what is listed under "external libraries" in project view?
Regards, Oleg.
Attachment(s):
second.zip
I get the same thing running in command line. But this is something different than from what I get in the IDE. In command line it at least is trying. In the IDE it throws the white flag before even attempting to do something.
Here's my rvm and gem list:
$ rvm current
ruby-1.9.2-p320
$ gem list
*** LOCAL GEMS ***
ansi (1.4.3)
archive-tar-minitar (0.5.2)
builder (3.1.4)
bundler (1.2.3)
columnize (0.3.6)
hashie (1.2.0)
linecache19 (0.5.12)
minitest (4.3.3)
minitest-reporters (0.13.1)
powerbar (1.0.11)
rake (10.0.3)
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.17.beta14)
ruby_core_source (0.1.5)
rubygems-bundler (1.1.0)
rvm (1.11.3.5)
test-unit (2.5.3)
BTW - when using test/unit, everything works perfectly from command line.
Attachment(s):
external lib.png
Bother... I've found what is the problem which cause the difference. It is our bug :(
Good news: it is fixed in the latest RM 5.0 EAP build.
And yes, it is only reproducible when you do not use bundler (projects w/o bundler is not a mainstream and we overlooked this problem :(
Sorry.
Oleg.
Appreciate your persistance. Always good to know I am not as incompetent as I thought.
So the new fix wil solve both the minitest runner problem and the test reporter attachment one?
Will be awaiting the new version, and will try working with bundle.
one more stupid question, if I may, please.
So now I am running with bundler, as per your suggestion, and everything is hunky doy when using the IDE.
What do I need to in rorder to still be running the tests from command line.
since I started using bundler I am getting this kind of error when trying to run the test in terminal:
/ruby-1.9.2-p320/gems/minitest-reporters-0.13.1/lib/minitest/reporter.rb:4:in `runner': undefined method `runner' for MiniTest::Unit:Class (NoMethodError)
Sorry for the trouble and thanks again
Nevermind... I think...
Added a gem 'minitest' in the test file and I'm OK.
I guess I still need to brush up on my bundling skills from without the context of the sdk.
The fix is about using correct version of minitest. This will fix problem with attaching RM to tests.
Oleg.
The correct way to run something on bundler's context is "bundle exec ..."
Regards, Oleg.