Unable to attach test reporter... (newbie question)
Greetings!
Disclaimer: I'm extremely new to Ruby, and I'm getting very frustrated w/ this issue.
I'm trying to use Ruby 1.9.3 and do some basic unit tests. I have spent nearly a day trying to figure this out, and have got close, but come up dry. I've boiled this down to about the simplest I can (I hope).
I have the following Project structure, in ~/Dev/RubyTest193/
app/my_object.rb
test/myobject_test.rb
test/test-helper.rb
Gemfile
the contents are such:
app/my_object.rb
class MyObject
def initialize( a_value )
@my_value = a_value
end
attr_accessor :my_value
end
test/myobject_test.rb
require "test/unit"
require "./app/my_object"
class MyObjectTest < Test::Unit::TestCase
def test_can_create_myobject
me = MyObject.new( 42 )
assert_not_nil( me )
end
def test_fail
fail("Test to show failure")
end
end
test/test-helper.rb
require 'minitest/reporters'
MiniTest::Unit.runner = MiniTest::SuiteRunner.new
if ENV["RM_INFO"] || ENV["TEAMCITY_VERSION"]
MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMineReporter.new
elsif ENV['TM_PID']
MiniTest::Unit.runner.reporters << MiniTest::Reporters::RubyMateReporter.new
else
MiniTest::Unit.runner.reporters << MiniTest::Reporters::ProgressReporter.new
end
Gemfile
source "https://rubygems.org"
group :test do
gem "minitest"
gem "minitest-reporters"
end
# gem "rails"
The tests do run, I see the output (1 pass, 1 fail) in the console window. However, I see the dreaded 'Unable to attach test reporter to test framework or test framework quit unexpectedly"
If I copy the contents fo the test/test-helper.rb into the test/myobject_test.rb, I see the results (one failed test).
I realize this has to be a very serious noob error, but I cannot figure this out. If I failed to include any info, I'll glady post what I can.
I'm running RubyMine 4.0.2 (Mac although when used on the PC, I have the same issue)
I have the minitest and minitest-reporters gems installed and up to date (as of this post)
Thanks for taking the time to read this
-B
Please sign in to leave a comment.
Hi,
I think you just need to add
require 'test-helper'
to myobject_test.rb.
The help suggest to add the code to test-helper.rb because it assumes that you have RoR application
and in this case every test will include test-helper be default.
Hope this helps :)
Oleg,
Many thanks!
That was it. I knew it had to be something dumb on my end. I did an epic face palm when I read this. I can't believe I didn't think of that.
Thanks again for taking the time to answer this.
-B
you are always welcome :)