BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Boost your Java Test with Ruby and JtestR

| by Sebastien Auvray on Jan 07, 2008. Estimated reading time: 1 minute |
The ease of Ruby for scripting tasks makes it a very powerful candidate for writing your Test suites. Until recently, there was no real standalone framework to test your Java with Ruby. JtestR written by Ola Blini (a member of JRuby team) and Anda Abramovici makes it possible now.

The main project is a collection of Ruby libraries bundled together with JRuby integration. It also includes the well known libraries in the Ruby world: RSpec (for BDD), mocha (for mocking and stubbing), dust (descriptive block syntax test definition), Test/Unit, and ActiveSupport (Ruby utility classes).

You'll end up with test case looking like this (RSpec wise) :
import java.util.HashMap

describe "An empty", HashMap do
 before :each do
 @hash_map = HashMap.new
 end
 it "should be able to add an entry to it" do
 @hash_map.put "foo", "bar"
  @hash_map.get("foo").should == "bar"
 end
 it "should return a keyset iterator that throws an exception on next" do
 proc do
 @hash_map.key_set.iterator.next
 end.should raise_error(java.util.NoSuchElementException)
 end
end
As an Ant task JtestR supports Ant, buildr and Maven2 integration.

Notice that JtestR relies on JRuby (which is still in heavy development) and that if you're running your tests often, you should set up the server Ant task to avoid JRuby heavy startup time (as described in the Getting Started tutorial).

With 0.1.1 version JtestR is in its early releases and your feedback will than welcome to guide its future direction.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and dont miss out on content that matters to you

BT