Empty project setup for unit testing

Hi all,
     I'm from a .NET background trying to satisfy an itch to learn Ruby. I'm trying to get a simple Hello World style empty project going but having trouble understanding how I have to set up the project so the tests work correctly. I created a dir called test and one called app, added a test file and pressed run and although it executes the test I get an error in the output which says...

Unable to attach test reporter to test framework or test framework quit unexpectedly

...Is there some additional set up I need to perform in order to get the test runner working correctly?

I would like to build my application core outside of rails and include it as a gem at a later date but I just can't get off the ground in a non-rails environment.

7 comments
Comment actions Permalink

Hello Rob,

Ruby 1.9 replaced test/unit framework with minitest, that requires some additional steps to set up. You can read more here. In general you can simply install minitest and minitest-reporters gems and add following to the beginning of your test.

require 'minitest/reporters'
MiniTest::Reporters.use!
0
Comment actions Permalink

Hi Dennis thanks for the reply.

Okay I'm following some of the link you sent me and it is helpful. I got to this stage before but it's still not right and I thing it has something to do with my understanding of the gems.

The link states...

The gems have to be properly attached to your project. For example, if you use the Bundler for managing gems, the required gems should be added to the Gemfile of your project.

Do all projects require a bundler or is just having the gems installed enough? I've attached the require and use to my test file but now when a test runs and fails an assert, the icons are still green, the test bar contains no feedback whatsoever and the output window is not describing how my tests are failing "expected x but got z etc" which I am getting if I don't follow the steps in that wiki.

Am I missing something?

0
Comment actions Permalink

Could you please attach your test project so I could check what's the problem?

0
Comment actions Permalink

Here's my test class. Is it because the test class is still inheriting from Test or something and the old test/unit require is still there? I've tried taking them out but to no avail.



Attachment(s):
game_test.rb.zip
0
Comment actions Permalink

Sorry just realised you said project...



Attachment(s):
BowlingKata.zip
0
Comment actions Permalink

Looks like running with minitest-reporters without bundler causes some conflict between minitest gem and built-in minitest. You can add Gemfile with the following content as a workaround:

gem 'minitest'
gem 'minitest-reporters'
and selecting bundle exec in Bundler tab in run configuration.
We'll take a look at this problem.

0
Comment actions Permalink

That did indeed fix it thank you :)

Hopefully you guys will be able to fix it so it works out of the box.

Thanks again.

Rob

0

Please sign in to leave a comment.