Forum: Ruby on Rails Running Rails Tests in Eclipse Test::Unit GUI

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
97cbca14d17274370cce501bbea7980a?d=identicon&s=25 Mike Harris (Guest)
on 2006-01-30 15:14
(Received via mailing list)
Maybe this is common knowledge, I don't know.  I figured I'd post it,
hopefully it can help some people.  If anyone has a better way, please
share. (not my blog, I'm Mike in the comments

I couldn't get it to literally run the test in the identical way as
rails does when you type rake. However, I could get it to run an
individual test file in the GUI, by opening the file and picking Run As
Test::Unit Test off the menu. From there, I figured why fight to do it
the "elegant" way when I can just create a new file that requires all my
test files. There's no reason one couldn't get it identical to the "rake
way," but I didn't feel like fighting any more.

I made a new file in the test directory, I called it all_tests.rb but
you can call it whatever you want. The contents is (one line):

["unit","functional"].each { |t| Dir.foreach("test/#{t}") { |f| require
"test/#{t}/#{f}" if f =~ /.*\.rb/} }

There's no need for it to be a one-liner, I made it that way cause ....
well cause of the same reason anyone makes an unnecessary one liner, for
fun. That will call "require" on each one of your test files. If you
have additional directories other than unit and functional with test
files, just add them in the array.

Run that file with Run As/Test::Unit Test and it should run all your
tests in the GUI. I remapped Run As Test::Unit Test to Ctrl-T in my
environment, just for convienence, so it's open that file/Ctrl-T.
Obviously that's optional.

It's not QUITE as convienent as the ideal (a keystroke AND A MOUSE
CLICK?!?!?!?!?!?!?!?!?!) but it's pretty darn good.
E48d29dc8fedb2878fa518d41cc63d88?d=identicon&s=25 Jan Prill (Guest)
on 2006-01-30 15:48
(Received via mailing list)
Hey Mike,

thanks for sharing this. I've just tried it. Works great!

Jan Prill
This topic is locked and can not be replied to.