A passion, technology.
Imagine a working environment which promotes technological innovation and curiosity.
Imagine a group where you will have opportunity to work and to share with people among the most gifted.
Imagine a culture and stocks in break with SSII.
Imagine a society where your talents and your ideas will be admitted and encouraged.
Imagine an organisation which gives you the medium reals to work, to advance, to accomplish your personal plans.
Do not imagine any more, live him!
Do not hesitate to contact us across the Form of contact or directly at address recrutement@xebia.fr.
ADDM Adobe Android annotation GAPED development Devoxx Eclipse ESB WORKING FLASH FLEX GOOGLE GROOVY GWT HIBERNATE IBM J2EE POPULAR DANCE JAVAFX JAZOON JBOSS jdk-7 scala SCRUM SOA JEE JPA JSF JVM agile Methods MAVEN ORACLE OSGI PARIS JUG PERFORMANCE RIA SPRING SPRINGSOURCE SUN TOMCAT WEBSPHERE WICKET XEBIA XP
Xebia is a brain tumour, exclusively devoted to technologies J2EE.
Except opposite mention, the contents of this blog are under contract Creative Commons.
Among the inevitable tasks of the life of a developer, there is the writing of the unit tests. Many tools try to make life easier for us on this point. Today, I am going to speak to you of , a framework of unit tests who brings power and speed of writing of the scripting to test Popular dance applications. Thrown by Ola Bini, an inevitable contributor the plan JRUBY, JTESTR is directly integrable with Ant, Buildr and Maven 2. This plan is not still very spread, but it brings advantages which are worth being studied.
JTESTR is group of bookshops Ruby devoted to tests, alloyed in JRUBY to allow a quick starting and without pain of the writing of tests. One of the main trumps of the scripting is the speed of writing, and Ruby is a language of scripting become very popular these last years, notably thanks to Ruby one Rails. The unit tests and of integration make integral part of the world Ruby and several tools came into the world to make them easier. JTESTR loads the bookshops of test Ruby following:
As tool Popular dance, he also allows correlations with frameworks:
In its last version, JTESTR requires the use of Popular dance 1.6.
Delivered in the form of a jar with a task Ant, it is easily integrable in an existent plan. Once the available jar in your classpath, it is enough to add a beacon taskdef in your build for more comfort and the turn is played:
<JTESTR/>
</target>
For plans Maven, a modification minor of the pom will suit:
The directive of shape tests allows to specify the directory in which to search the scripts of tests. To keep mind Maven, I recommend you to create a directory src/test/ruby and to put all tests there. The hierarchy in pence directories to represent the packages of classes to be tested does not put down worries.
JTESTR gives several possibilities for the writing of tests. First of all, the use of the framework of Ruby's academic tests:Test::Unit. It does not bring tests JUNIT from big novelty in comparison with classics. The Swiss knife of method assert am available similarly.
Example of Test:: Joins
def test_that_map_is_empty
assert @map.isEmpty
end
def test_that_it_returns_a_keyset_that_returns_an_iterator_that_throws_exception
assert_raises (java.util. NOSUCHELEMENTEXCEPTION) do
@map.key_set.iterator.next
end
end
end
But it is also possible to use RSPEC. This framework of tests is orientated "specification" and offers an original notation which tends to bring closer to the writing of the tests of the specification of waited behaviour. Compared notation:
# with RSPEC
result.should == 42
They get closer so to the natural language. In English in the text, certainly, but they get closer. The structure of a complete file RSPEC gives for example:
describe "a Year empty", HashMap do
before:each do
@hash_map = HashMap.new
end
it "should not be empty After a year entry has been added to it" do
@hash_map.put "Foo", "bar"
@hash_map.should_not be_empty
end
it " should be empty " do
@hash_map.should be_empty
@hash_map.size.should == 0
end
it "should return has exception keyset iterator that throws a year they next" do
proc do
@hash_map.key_set.iterator.next
end.should raise_error (java.util. NOSUCHELEMENTEXCEPTION)
end
end
It is possible to mix Test in the same plan of tests:: Joins tests RSPEC and. The respect for a norm of naming of files is enough in JTESTR to determine the directed framework.
An important precision on an obscure point in material: order import search in beginning packages by java, javax, org and com. For all the others it is necessary to write:
A problem which can be checked off of the finger is the time of load of environment JRUBY. The interpreter indeed takes sometimes more than 10 seconds to launch. To overcome this problem, JTESTR has a mode server which allows to keep a server in thorough task with environment JRUBY in waiting of tests to be thrown. The time of load is easily abolished so.
The training of the bases of language Ruby can also cast down, but it is a weak obstacle as much as it is a language entirely object and where classes Popular dance of plan are predominantly manipulated to be tested. The step is rather easily generally crossed.
The offer of frameworks of tests is already consequent in the world Popular dance. JTESTR is not very spread at present. Nevertheless, the use of RSPEC for the writing of tests allows to remain close to a verbal formulation of waited behaviours. In a step TDD, it can be favourable. They will have so tendency to avoid getting lost in technical formulations from the first stages of plan.
Besides, I will take JTESTR into consideration seriously if I had developers Ruby in my team. The framework gives you a chance to break border between your teams Ruby et Java. The very concise aspect of tests makes them legible as much by the developers Popular dance as Ruby and reinforces mutual assistance between teams. It makes easier the distribution of competences and of knowledge between developers, what is never a bad thing.
Resources:
Tickets on the same topic:
You can follow answers accepted by this article thanks to the thread of comments.
Xebia it Architects lock France
Defence Colis e - 10/12, avenue of The Ark
92419 Courbevoie Cedex
T l : +33 (0) 1 46 91 76 16
Fax : +33 (0) 1 46 91 88 00
E-mail : info@xebia.fr