Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing JUnit 4 tests in JRuby

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
I'm considering writing JUnit 4 tests in JRuby instead of Java.
I might missed it but I googled it and found nothing about writing JUnit 4 tests in JRuby.
Is it possible to do this?
Thanks.
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

You might want to have a look at the comments on this page
Charles Oliver Nutter added a comment - 03/Feb/09 9:58 PM
I'm resolving this as "duplicate" because there are other bugs to track eventual development of a "compiler #2"
that can create normal Java classes, at which time all annotation-based libraries should work fine. So there's not
really a need to track JUnit4 independent of the larger task of building that compiler.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends. No annotations in JRuby (last I checked), since that would be a syntactical extension. But you can extend Java classes.

I guess I'd ask why, if you're using JRuby anyway, you wouldn't just write something using a Ruby test framework--much cleaner.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use RSpec and Cucumber to test Java code?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course; why wouldn't it be? JRuby allows unfettered access to Java classes.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, this looks really powerful and useful.
So if I wrote my tests with JRuby and Ruby testing libraries, how to run them? with Rake or Ant?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same way you'd run them in Ruby. JRuby *is* Ruby, on the JVM. Modulo some JNI libraries, anything you can do in Ruby you can do with JRuby. Gems work. Libraries work. Ruby works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic